Release Notes for MongoDB 5.0

On this page本页内容

Note注意

MongoDB 5.0 Released Jul 13, 2021MunGDB 5发布于2021年7月13日

Patch Releases补丁发布

5.0.6 - January 31, 2022

Issues fixed:已修复问题:

  • WT-8395 Inconsistent data after upgrade from 4.4.3 and 4.4.4 to 4.4.8+ and 5.0.2+
  • SERVER-62245 MigrationRecovery must not assume that only one migration needs to be recovered
  • SERVER-61427 Unique index builds can cause a loss of availability during commit due to checking many false duplicates
  • SERVER-61194 Prevent time-series bucket OID reuse with coarse granularity
  • SERVER-60310 OCSP response validation should not consider statuses of irrelevant certificates
  • All JIRA issues closed in 5.0.6
  • 5.0.6 Changelog

5.0.5 - December 6, 2021

Issues fixed:已修复问题:

  • SERVER-61483 Resharding coordinator fails to recover abort decision on step-up, attempts to commit operation as success, leading to data inconsistency
  • SERVER-59858 Add observability for tasks scheduled on the reactor thread
  • SERVER-51329 Unexpected non-retryable error when shutting down a mongos server关闭mongos服务器时出现意外的不可重试错误
  • WT-8163 Consider more eviction scenarios to give up checkpoint-cleanup
  • WT-7912 Fix prefix search near optimisation to handle scenarios where the key range is split across pages.
  • All JIRA issues closed in 5.0.5
  • 5.0.5 Changelog

5.0.4 - Nov 15, 2021

Issues fixed:已修复问题:

5.0.3 - Sep 21, 2021

Issues fixed:已修复问题:

  • SERVER-57667: Improve processing speed for resharding's collection cloning pipeline
  • SERVER-57630: Enable SSL_OP_NO_RENEGOTIATION on Ubuntu 18.04 when running against OpenSSL 1.1.1
  • WT-8005: Fix a prepare commit bug that could leave the history store entry unresolved
  • WT-7995: Fix the global visibility that it cannot go beyond checkpoint visibility
  • WT-7984: Fix a bug that could cause a checkpoint to omit a page of data
  • All JIRA issues closed in 5.0.3
  • 5.0.3 Changelog

5.0.2 - Aug 4, 2021

Warning警告

MongoDB version 5.0.2 is not recommended for production use due to critical issues WT-7984 and WT-7995, fixed in later versions. 由于WT-7984WT-7995的关键问题,不建议将MongoDB 5.0.2版用于生产,该问题已在更高版本中修复。Use the latest available patch release version.请使用最新的可用补丁发布版本。

Issues fixed:已修复问题:

5.0.1 - Jul 22, 2021

Warning警告

MongoDB version 5.0.1 is not recommended for production use due to critical issues SERVER-58936, WT-7984, and WT-7995, fixed in later versions. Use the latest available patch release version.

Issues fixed:已修复问题:

  • SERVER-58489: Collection creation stuck in an infinite writeConflictRetry loop when having a duplicate name as a view:当视图具有重复名称时,集合创建卡在无限WriteConflictry循环中
  • SERVER-58171: Changing time-series granularity does not update view definition:更改时间序列粒度不会更新视图定义
  • All JIRA issues closed in 5.0.1
  • 5.0.1 Changelog

5.0.0 - Jul 13, 2021

Warning警告

MongoDB version 5.0.0 is not recommended for production use due to critical issues SERVER-58936, WT-7984, and WT-7995, fixed in later versions. 由于SERVER-58936WT-7984WT-7995的关键问题,不建议生产使用MongoDB 5.0.0版,这些问题在更高版本中已修复。Use the latest available patch release version.使用最新的可用补丁发布版本。

The rest of this page provides the 5.0.0 release notes:本页其余部分提供了5.0.0发行说明:

Time Series Collections时间序列集合

MongoDB 5.0 introduces time series collections which efficiently store sequences of measurements over a period of time. MongoDB 5.0引入了时间序列集合,可以有效地存储一段时间内的测量序列。Compared to normal collections, storing time series data in time series collections improves query efficiency and reduces disk usage for your data and indexes.与普通集合相比,在时间序列集合中存储时间序列数据可以提高查询效率,并减少数据和索引的磁盘使用。

Aggregation聚合

New Aggregation Operators新的聚合运算符

MongoDB 5.0 introduces the following aggregation operators:MongoDB 5.0引入了以下聚合运算符:

Operator运算符Description描述
$count

$count (aggregation accumulator) provides a count of all documents when used in the existing pipeline $group (aggregation) stage and the new MongoDB 5.0 $setWindowFields stage.提供在现有管道$group(聚合)阶段和新的MongoDB 5.0$setWindowFields阶段中使用的所有文档的计数。

Note注意
Disambiguation消除歧义

The $count (aggregation accumulator) is distinct from the $count (aggregation) pipeline stage.$count(聚合累加器)不同于$count(聚合)管道阶段。

$dateAddIncrements a Date object by a specified number of time units.按指定的时间单位递增Date对象。
$dateDiffReturns the difference between two dates.返回两个日期之间的差值。
$dateSubtractDecrements a Date object by a specified number of time units.按指定的时间单位数递减Date对象。
$dateTruncTruncates a date.截断日期。
$getFieldReturns the value of a specified field from a document. 返回文档中指定字段的值。You can use $getField to retrieve the value of fields with names that contain periods (.) or start with dollar signs ($).可以使用$getField检索名称中包含句点(.)的字段的值或者从美元符号($)开始。
$randThe $rand method generates a random float value between 0 and 1 each time it is called. $rand方法每次调用时都会生成一个介于0和1之间的随机浮点值。The new $sampleRate operator is based on $rand. 新的$sampleRate运算符基于$rand(Also added to MongoDB 4.4.2)(也添加到MongoDB 4.4.2中)
$sampleRateAdds the $sampleRate method to probabilistically select documents from a pipeline at a given rate.添加$sampleRate方法,以按给定速率从管道中概率选择文档。
$setFieldAdds, updates, or removes a specified field in a document. 添加、更新或删除文档中的指定字段。You can use $setField to add, update, or remove fields with names that contain periods (.) or start with dollar signs ($).可以使用$setField添加、更新或删除名称中包含句点(.)或者从美元符号($)开始。
$unsetFieldRemoves a specified field in a document. 删除文档中的指定字段。An alias for $setField to remove fields with names that contain periods (.) or that start with dollar signs ($).$setField的别名,用于删除名称中包含句点(.)或者以美元符号($)开头。

Window Operators窗口运算符

MongoDB 5.0 introduces the $setWindowFields pipeline stage, allowing you to perform operations on a specified span of documents in a collection, known as a window. MongoDB 5.0引入了$setWindowFields管道阶段,允许您对集合中指定范围的文档(称为“窗口”)执行操作。The operation returns the results based on the chosen window operator.该操作基于所选的窗口运算符返回结果。

For example, you can use the $setWindowFields stage to output the:例如,您可以使用$setWindowFields阶段输出:

  • Difference in sales between two documents in a collection.一个集合中两个文档之间的销售差异。
  • Sales rankings.销售排名。
  • Cumulative sales totals.累计销售总额。
  • Analysis of complex time series information without exporting the data to an external database.在不将数据导出到外部数据库的情况下分析复杂的时间序列信息。

General Aggregation Improvements总体聚合改进

$expr Operator: Comparison Operators Use Indexes运算符:比较运算符使用索引

Starting in MongoDB 5.0, the $eq, $lt, $lte, $gt, and $gte operators placed in an $expr operator can use indexes to improve performance.从MongoDB 5.0开始,放置在$expr运算符中的$eq$lt$lte$gt$gte运算符可以使用索引来提高性能。

$ifNull Expression Accepts Multiple Input Expressions表达式接受多个输入表达式

Starting in MongoDB 5.0, you can specify multiple input expressions for the $ifNull expression before returning a replacement expression.从MongoDB 5.0开始,在返回替换表达式之前,可以为$ifNull表达式指定多个输入表达式。

let Option for Aggregation用于聚合的let选项

Starting in MongoDB 5.0, the aggregate command and db.collection.aggregate() helper method have a let option to specify a list of variables that can be used elsewhere in the aggregation pipeline. 从MongoDB 5.0开始,aggregate命令和db.collection.aggregate()助手方法有一个let选项,用于指定可在聚合管道中其他地方使用的变量列表。This allows you to improve command readability by separating the variables from the query text.这允许您通过将变量与查询文本分离来提高命令的可读性。

$lookup Stage: Concise Correlated Subqueries阶段:简明相关子查询

Starting in MongoDB 5.0, an aggregation pipeline $lookup stage supports concise correlated subqueries that improve joins between collections.从MongoDB 5.0开始,聚合管道$lookup阶段支持简洁的相关子查询,从而改善集合之间的连接。

$lookup Stage: Uncorrelated Subqueries阶段:不相关子查询

Starting in MongoDB 5.0, for an uncorrelated subquery in a $lookup pipeline stage containing a $sample stage, the $sampleRate operator, or the $rand operator, the subquery is always run again if repeated. 从MongoDB 5.0开始,对于$lookup管道阶段中包含$sample阶段、$sampleRate运算符或$rand运算符的不相关子查询,如果重复,子查询始终会再次运行。Previously, depending on the subquery output size, either the subquery output was cached or the subquery was run again.以前,根据子查询输出的大小,可以缓存子查询输出,也可以再次运行子查询。

See Perform an Uncorrelated Subquery with $lookup.请参阅使用$lookup执行不相关子查询

Auditing审计

Runtime Audit Filter Configuration运行时审计筛选器配置

MongoDB 5.0 adds the ability to configure auditing filters at runtime.MongoDB 5.0增加了在运行时配置审计筛选器的功能。

Operator运算符Description描述
auditConfigPollingFrequencySecsDefines the polling interval for checking audit configuration定义检查审计配置的轮询间隔
getAuditConfigRetrieves audit configurations from mongod and mongos.mongodmongos检索审计配置。
setAuditConfigSets new audit configurations for mongod and mongos instances at runtime.在运行时为mongodmongos实例设置新的审计配置。

General Auditing Updates一般审计更新

Starting in MongoDB 5.0:从MongoDB 5.0开始:

Change Streams更改流

Change Events Output更改事件输出

Starting in MongoDB 5.0, Change Events contain the field updateDescription.truncatedArrays to record array truncations.从MongoDB 5.0开始,Change事件包含updateDescription.truncatedArrays字段,用于记录数组截断。

Indexes索引

Partial Indexes Behavior Change部分索引行为改变

Starting in MongoDB 5.0, multiple partial indexes can be created using the same key pattern as long as the partialFilterExpression fields do not express equivalent filters.从MongoDB 5.0开始,只要partialFilterExpression字段不表示等效的筛选器,就可以使用相同的键模式创建多个部分索引

In earlier versions of MongoDB, creating multiple partial indexes is not allowed when using the same key pattern with different partialFilterExpressions.在早期版本的MongoDB中,当对不同的partialFilterExpressions使用相同的密钥模式时,不允许创建多个部分索引

Unique Sparse Index Behavior Change唯一稀疏索引行为变化

Starting in MongoDB 5.0, unique sparse and unique non-sparse indexes with the same key pattern can exist on a single collection.从MongoDB 5.0开始,具有相同键模式唯一稀疏索引和唯一非稀疏索引可以存在于单个集合中。

See unique sparse index creation请参见创建唯一稀疏索引

Cannot Drop Ready Indexes During In-Progress Index Builds无法在进行中的索引生成期间删除Ready索引

The db.collection.dropIndexes() command cannot drop ready indexes if there are any in-progress index builds.如果存在任何正在进行的索引生成,则db.collection.dropIndexes()命令无法删除就绪索引

  • In versions 4.4.0-4.4.4 of MongoDB, this logic was not true due to a bug.在MongoDB的4.4.0-4.4.4版本中,由于一个bug,该逻辑不正确。

Foreground Validation May Fix Multikey Metadata Inconsistencies前台验证可能会修复多键元数据不一致的问题

When run on a MongoDB deployment, db.collection.validate() attempts to fix multikey metadata inconsistencies of standalone deployments.在MongoDB部署上运行时,db.collection.validate()会尝试修复独立部署的多键元数据不一致

Removal of geoHaystack Index and the geoSearch Command删除geoHaystack索引和geoSearch命令

MongoDB 5.0 removes the deprecated geoHaystack index and geoSearch command. MongoDB 5.0删除了不推荐使用的geoHaystack索引和geoSearch命令。Use a 2d index with $geoNear or one of the supported geospatial query operators instead.使用带有$geoNear2d索引或受支持的地理空间查询运算符之一。

Upgrading your MongoDB instance to 5.0 and setting featureCompatibilityVersion to 5.0 will delete any pre-existing geoHaystack indexes.将MongoDB实例升级到5.0并将featureCompatibilityVersion设置为5.0将删除任何预先存在的geoHaystack索引。

New Error Messages新的错误消息

The db.collection.createIndex() and db.collection.createIndexes() operations have new error messages when options are specified incorrectly.当选项指定不正确时,db.collection.createIndex()db.collection.createIndexes()操作会出现新的错误消息。

Interrupted Index Builds中断索引构建

If a node in a replica set is cleanly shutdown or rolls back during an index build, the index build progress is now saved to disk. 如果副本集中的节点在索引生成期间完全关闭或回滚,则索引生成进度现在保存到磁盘When the server restarts, index creation resumes from the saved position.服务器重新启动时,索引创建将从保存的位置恢复。

reIndex Behavior Change行为改变

Starting in MongoDB 5.0, the reIndex command and the db.collection.reIndex() shell method may only be run on standalone instances.从MongoDB 5.0开始,reIndex命令和db.collection.reIndex() shell方法只能在独立实例上运行。

Removed Commands被删除的命令

Starting in MongoDB 5.0, these database commands and mongo shell helper methods are removed:从MongoDB 5.0开始,删除以下数据库命令和mongo shell 助手方法:

Removed Command被删除的命令Alternative可供替代的
db.collection.ensureIndex()db.collection.createIndex()
db.resetError()Not available不可用
resetErrorNot available不可用
shardConnPoolStatsconnPoolStats
unsetShardingNot available不可用
geoSearch$geoNear or one of the supported geospatial query operators或支持的地理空间查询运算符之一

Replica Sets复制集

Non-transactional Reads on config.transactionsconfig.transactions上的非事务读取

Starting in MongoDB 5.0, non-transaction reads are not allowed on the config.transactions collection with the following read concerns and options:从MongoDB 5.0开始,config.transactions集合上不允许进行非事务读取,具有以下读取问题和选项:

hello Command命令

Starting in MongoDB 5.0 (and 4.4.2, 4.2.10, 4.0.21, and 3.6.21), the hello command and the db.hello() method were introduced as replacements for the isMaster command and the db.isMaster() method. 从MongoDB 5.0(以及4.4.2、4.2.10、4.0.21和3.6.21)开始,hello命令和db.hello()方法被引入,以替代isMaster命令和db.isMaster()方法。The new topology metric connections.exhaustHello tracks this in connections.新的拓扑度量connections.exhaustHelloconnections中跟踪这一点。

Quiesce Period静止期

Starting in MongoDB 5.0, mongod and mongos enter a quiesce period to allow any ongoing database operations to complete before shutting down.从MongoDB 5.0开始,mongodmongos进入一个静止期,允许任何正在进行的数据库操作在关闭之前完成。

Limit Removed for members[n]._id Valuesmembers[n]._id值的限制删除

Starting in MongoDB 5.0, the members[n]._id field may be any integer value greater than or equal to 0. 从MongoDB 5.0开始,members[n]._id字段可以是大于或等于0的任何整数值。Previously, this value was limited to an integer between 0 and 255 inclusive.以前,该值被限制为0255(包含0255)之间的整数。

enableMajorityReadConcern Is Not Configurable不可配置

Starting in MongoDB 5.0, enableMajorityReadConcern and --enableMajorityReadConcern cannot be changed and are always set to true due to storage engine improvements.从MongoDB 5.0开始,由于存储引擎的改进,enableMajorityReadConcern--enableMajorityReadConcern无法更改,并且始终设置为true

In earlier versions of MongoDB, enableMajorityReadConcern and --enableMajorityReadConcern are configurable and can be set to false to prevent storage cache pressure from immobilizing a deployment with a three-member primary-secondary-arbiter (PSA) architecture.在早期版本的MongoDB中,enableMajorityReadConcern--enableMajorityReadConcern是可配置的,可以设置为false,以防止存储缓存压力阻止使用三成员主从仲裁器(PSA)体系结构的部署。

If you are using a three-member primary-secondary-arbiter (PSA) architecture, the write concern "majority" can cause performance issues if a secondary is unavailable or lagging. 如果您使用的是三成员主从仲裁器(PSA)体系结构,那么如果次要仲裁器不可用或滞后,写问题"majority"可能会导致性能问题。See Mitigate Performance Issues with PSA Replica Set for advice on how to mitigate these issues.有关如何缓解这些问题的建议,请参阅缓解PSA副本集的性能问题

Enhanced Thread Pool Timeout Control增强的线程池超时控制

Starting in MongoDB 5.0, you can use the new replWriterMinThreadCount server parameter to configure the timeout of idle threads in the thread pool for parallel execution of replication operations. 从MongoDB 5.0开始,您可以使用新的replWriterMinThreadCount服务器参数来配置线程池中空闲线程的超时,以便并行执行复制操作。When replWriterMinThreadCount is configured with a value less than replWriterThreadCount, idle threads above replWriterMinThreadCount are timed out.replWriterMinThreadCount配置为小于replWriterThreadCount的值时,高于replWriterMinThreadCount的空闲线程将超时。

Reconfiguring PSA Replica Sets重新配置PSA副本集

When reconfiguring primary-secondary-arbiter (PSA) replica sets or changing to a PSA architecture, it is now in some cases required to perform the reconfiguration in a two-step change. 当重新配置主从仲裁器(PSA)副本集或更改为PSA体系结构时,在某些情况下,现在需要以两步更改的方式执行重新配置。MongoDB 5.0 introduces the rs.reconfigForPSASet() method which performs both steps. MongoDB 5.0引入了rs.reconfigForPSASet()方法,该方法执行这两个步骤。If you cannot use the helper method, follow the procedure in Modify PSA Replica Set Safely.如果无法使用助手方法,请按照安全修改PSA副本集中的步骤操作。

Limit Sync Source Re-evaluations限制同步源重新评估

maxNumSyncSourceChangesPerHour determines how many sync source changes can happen per hour before the node temporarily stops re-evaluating a sync source. 确定在节点临时停止重新评估同步源之前,每小时可以发生多少次同步源更改。This parameter will not prevent a node from starting to sync from another node if it doesn't have a sync source.如果一个节点没有同步源,此参数不会阻止该节点开始与另一个节点同步。

enableOverrideClusterChainingSetting Server Parameter服务器参数

Starting in MongoDB 5.0.2 (and 4.2.16 and 4.4.8), you can set the new enableOverrideClusterChainingSetting server parameter to true to allow secondary members to replicate data from other secondary members even if settings.chainingAllowed is false.从MongoDB 5.0.2(以及4.2.16和4.4.8)开始,您可以将新的enableOverrideClusterChainingSetting服务器参数设置为true,以允许辅助成员从其他辅助成员复制数据,即使settings.chainingAllowedfalse

Security安全

Support for Online Certificate Rotation支持在线证书轮换

Starting in MongoDB 5.0, you may now rotate the following TLS certificates on demand without first needing to stop your running mongod or mongos instance:从MongoDB 5.0开始,您现在可以根据需要轮换以下TLS证书,而无需首先停止运行mongodmongos实例:

To rotate these certificates, replace the certificate files on your filesystem with updated versions, then use the rotateCertificates command or the db.rotateCertificates() shell method to trigger certificate rotation.要旋转这些证书,请用更新的版本替换文件系统上的证书文件,然后使用rotateCertificates命令或db.rotateCertificates() shell方法触发证书旋转。

Rotating certificates in this manner does not require downtime, and does not drop any active remote connections.以这种方式旋转证书不需要停机,也不会中断任何活动的远程连接。

See Online Certificate Rotation for full details.有关详细信息,请参阅在线证书轮换

Support for Configuring TLS 1.3 Cipher Suites支持配置TLS 1.3密码套件

MongoDB 5.0 introduces the opensslCipherSuiteConfig parameter to enable configuration of the supported cipher suites OpenSSL should permit when using TLS 1.3 encryption.MongoDB 5.0引入了opensslCipherSuiteConfig参数,以启用在使用TLS 1.3加密时OpenSSL应允许的受支持密码套件的配置。

TLS Connection X509 Certificate Startup WarningTLS连接X509证书启动警告

Starting in MongoDB 5.0, mongod and mongos now issue a startup warning when their certificates do not include a Subject Alternative Name attribute.从MongoDB 5.0开始,mongodmongos现在会在其证书不包含Subject Alternative Name属性时发出启动警告。

The following platforms do not support common name validation:以下平台不支持通用名称验证:

  • iOS 13 and higher
  • MacOS 10.15 and higher
  • Go 1.15 and higher

Clients using these platforms will not authenticate to MongoDB servers that use x.509 certificates whose hostnames are specified by CommonName attributes.使用这些平台的客户端不会向使用x.509证书的MongoDB服务器进行身份验证,该证书的主机名由CommonName属性指定

ApplyOps Privilege ActionApplyOps权限操作

MongoDB 5.0 introduces the applyOps privilege action which is inherited by dbAdminAnyDatabase.MongoDB 5.0引入了由dbAdminAnyDatabase继承的applyOps权限操作。

The applyOps action permits users to run the applyOps database command.applyOps操作允许用户运行applyOps数据库命令。

Sharded Clusters分片群集

Resharding重新分片

The ideal shard key allows MongoDB to distribute documents evenly throughout the cluster while facilitating common query patterns. 理想的切分密钥允许MongoDB在集群中均匀分布文档,同时促进常见的查询模式。A suboptimal shard key can lead to performance or scaling issues due to uneven data distribution. 由于数据分布不均匀,次优的分片密钥可能会导致性能或扩展问题。Starting in MongoDB 5.0, you can use the reshardCollection command to change the shard key for a collection to change the distribution of your data across your cluster.从MongoDB 5.0开始,您可以使用reshardCollection命令更改集合的分片键,以更改数据在集群中的分布。

currentOp Reports Ongoing Resharding Operations报告正在进行的再硬化操作

Starting in MongoDB 5.0, the $currentOp aggregation stage (and the currentOp command and db.currentOp() shell method) include additional information about the status of ongoing resharding operations for the resharding coordinator and the donor and recipient shards.从MongoDB 5.0开始,$currentOp聚合阶段(以及currentOp命令和db.currentOp() shell方法)包括有关重新存储协调器、捐赠者和接收者分片正在进行的重新存储操作状态的附加信息。

db.currentOp Method Now Uses Aggregation Stage in mongosh该方法现在在mongosh中使用聚合阶段

Starting in MongoDB 5.0, the $currentOp aggregation stage is used when running the helper method db.currentOp() with mongosh.从MongoDB 5.0开始,在使用mongosh运行助手方法db.currentOp()时使用$currentOp聚合阶段。

mongos / mongod Connection Pool连接池

Starting in MongoDB 5.0 (also available starting in 4.4.5 and 4.2.13), MongoDB adds the parameter option "automatic" as the new default for the ShardingTaskExecutorPoolReplicaSetMatching. 从MongoDB 5.0开始(也可以从4.4.5和4.2.13开始使用),MongoDB添加了参数选项"automatic",作为ShardingTaskExecutorPoolReplicaSetMatching的新默认值。When set for a mongos, the instance follows the behavior specified for the "matchPrimaryNode" option. mongos设置时,实例遵循为"matchPrimaryNode"选项指定的行为。When set for a mongod, the instance follows the behavior specified for the "disabled" option.mongod设置时,实例将遵循为"disabled"选项指定的行为。

renameCollection Compatible with Sharded Collections与分片集合兼容

Starting in MongoDB 5.0, you can use the renameCollection command to change the name of a sharded collection.从MongoDB 5.0开始,可以使用renameCollection命令更改分片集合的名称。

When renaming a sharded or unsharded collection in a sharded cluster, the source and target collections are exclusively locked on every shard. 重命名分片集群中的分片集合或未分片集合时,源集合和目标集合在每个分片上都被独占锁定。Subsequent operations on the source and target collections must wait until the rename operation completes.对源集合和目标集合的后续操作必须等待重命名操作完成。

movePrimary Error Message For Writes During Operation操作期间写入的错误消息

Starting in MongoDB 5.0, when using the movePrimary command to remove a shard from a sharded cluster, writes to the original shard will generate an error message.从MongoDB 5.0开始,当使用movePrimary命令从分片集群中删除分片时,写入原始分片将生成错误消息。

Split and Merge Chunk Changelogs Show Owning Shard拆分和合并区块更改日志显示拥有的分片

Starting in MongoDB 5.0, documents in the config.changelog collection for split and merge operations contain an owningShard field. 从MongoDB 5.0开始,用于拆分合并操作的config.changelog集合中的文档包含owningShard字段。The owningShard field shows the shardId of the shard that owns the chunks that were split or merged.owningShard字段显示拥有被拆分或合并的块的分片的shardId

The owningShard field helps identify shards where split or merge operations frequently occur.owningShard字段有助于识别经常发生拆分或合并操作的分片。

maxCatchUpPercentageBeforeBlockingWrites Server Parameter服务器参数

Starting in MongoDB 5.0 (and 4.4.7, 4.2.15, 4.0.26), you can set the maxCatchUpPercentageBeforeBlockingWrites to specify the maximum allowed percentage of data not yet migrated during a moveChunk operation when compared to the total size (in MBs) of the chunk being transferred.从MongoDB 5.0(以及4.4.7、4.2.15、4.0.26)开始,您可以设置maxCatchUpPercentageBeforeBlockingWrites,以指定在moveChunk操作期间,与正在传输的块的总大小(以MB为单位)相比,尚未迁移的数据的最大允许百分比。

This parameter can affect the behavior of:此参数可能会影响以下对象的行为:

Shell ChangesShell变化

New MongoDB Shell: 新MongoDB Shell:mongosh

The mongo shell has been deprecated in MongoDB v5.0. mongo Shell在MongoDB v5中已被弃用。0The replacement shell is mongosh. 替换的外壳是mongoshThe legacy mongo shell will be removed in a future release.遗留的mongo shell将在未来的版本中删除。

Shell packaging also changes in MongoDB v5.0. 在MongoDB v5中,Shell的包装也发生了变化。0Refer to the installation instructions for further details.有关更多详细信息,请参阅安装说明

Shell Support for GCP and Azure KMS ProvidersShell对GCP和Azure KMS提供商的支持

Starting in MongoDB 5.0 (and MongoDB 4.4.5), the Google Cloud Platform KMS and Azure Key Vault are supported in both mongosh and the legacy mongo shell as Key Management Service (KMS) providers for Client-Side Field Level Encryption.从MongoDB 5.0(和MongoDB 4.4.5)开始,Google云平台KMS和Azure密钥库在mongosh和传统mongo shell中都支持,作为客户端字段级加密的密钥管理服务(KMS)提供程序。

Using a KMS, you can centrally and securely store Customer Master Keys (CMKs), which are used to encrypt and decrypt data encryption keys as part of the client-side field level encryption workflow.使用KMS,您可以集中且安全地存储客户主密钥(CMK),作为客户端字段级加密工作流的一部分,这些密钥用于加密和解密数据加密密钥。

In addition, a configured KMS allows for the use of Automatic Field Decryption of data fields when used with MongoDB Enterprise.此外,配置的KMS允许在与MongoDB Enterprise一起使用时使用数据字段的自动字段解密

Instructions are available for both shells:这两种外壳都有说明:

Snapshots快照

Extended Support for Read Concern "snapshot"对读取关注点"snapshot"的扩展支持

Starting in MongoDB 5.0, read concern "snapshot" is supported for some read operations outside of multi-document transactions on primaries and secondaries.从MongoDB 5.0开始,在一级和二级上的多文档事务之外的一些读取操作支持读取关注点"snapshot"

minSnapshotHistoryWindowInSeconds Server Parameter服务器参数

Starting in MongoDB 5.0, you can use the minSnapshotHistoryWindowInSeconds parameter to control how long WiredTiger keeps the snapshot history.从MongoDB 5.0开始,可以使用minSnapshotHistoryWindowInSeconds参数来控制WiredTiger保留快照历史记录的时间。

Transactions事务

coordinateCommitReturnImmediatelyAfterPersistingDecision Parameter参数

Starting in MongoDB 5.0, the new server parameter coordinateCommitReturnImmediatelyAfterPersistingDecision controls when transaction commit decisions are returned to the client. 从MongoDB 5.0开始,新的服务器参数coordinateCommitReturnImmediatelyAfterPersistingDecision控制何时将事务提交决策返回给客户端。In previous versions of MongoDB, the shard transaction coordinator waited for all members to acknowledge a multi-document transaction commit before returning the commit decision to the client.在以前版本的MongoDB中,分片事务协调器等待所有成员确认多文档事务提交,然后将提交决定返回给客户端。

Naming Changes命名更改

Starting in February 2022, the "Versioned API" terminology was changed to "Stable API". All concepts and features remain the same with this naming change.从2022年2月开始,“版本化API”术语改为“稳定API”。所有的概念和功能在命名上都保持不变。

General Improvements总体改进

Capped Collection Deletes Process On Secondaries封顶集合删除Secondaries上的进程

Starting in MongoDB 5.0, the implicit delete operations of replica setcapped collections are processed by the secondary members.从MongoDB 5.0开始,复制集封顶集合隐式删除操作次要成员处理。

Execution Plan Statistics for Query with $lookup Pipeline Stage使用$lookup管道阶段查询的执行计划统计信息

MongoDB 5.0 adds execution plan statistics for queries that use a $lookup pipeline stage.MongoDB 5.0为使用$lookup管道阶段的查询添加了执行计划统计信息

Improved Handling of ($) and (.) in Field Names改进了对字段名中的($)和(.)的处理

MongoDB 5.0 adds improved support for field names that are ($) prefixed or that contain (.) characters. MongoDB 5.0增加了对前缀为($)或包含($)字符的字段名的改进支持The validation rules for storing data have been updated to make it easier to work with data sources that use these characters.存储数据的验证规则已经更新,以便更容易使用使用这些字符的数据源。

Cluster Wide Default Write Concern集群范围的默认写入问题

Starting in MongoDB 5.0, once the Cluster Wide Write Concern (CWWC) is set via the setDefaultRWConcern command the write concern cannot be unset.从MongoDB 5.0开始,一旦通过setDefaultRWConcern命令设置了集群范围的写关注点(CWWC),就不能取消设置写关注点。

Implicit Default Write Concern隐式默认写关注点

Starting in MongoDB 5.0, the implicit default write concern is w: majority. 从MongoDB 5.0开始,隐式的默认写入关注点w: majorityHowever, special considerations are made for deployments containing arbiters:但是,对于包含仲裁器的部署,需要特别考虑:

  • The voting majority of a replica set is 1 plus half the number of voting members, rounded down. 复制集的投票多数是1加一半的投票成员数,四舍五入。If the number of data-bearing voting members is not greater than the voting majority, the default write concern is { w: 1 }.如果带有数据的投票成员的数量不大于投票多数,则默认写关注点为{w:1}
  • In all other scenarios, the default write concern is { w: "majority" }.在所有其他场景中,默认的写关注点是{ w: "majority" }

Specifically, MongoDB uses the following formula to determine the default write concern:具体来说,MongoDB使用以下公式来确定默认写入关注点:

if [ (#arbiters > 0) AND (#non-arbiters <= majority(#voting-nodes)) ]
    defaultWriteConcern = { w: 1 }
else
    defaultWriteConcern = { w: "majority" }

For example, consider the following deployments and their respective default write concerns:例如,考虑以下部署和它们各自的默认写入关注点:

Non-Arbiters非仲裁人Arbiters仲裁人Voting Nodes投票节点Majority of Voting Nodes多数投票节点Implicit Default Write Concern隐式默认写关注点
2132{ w: 1 }
4153{ w: "majority" }
  • In the first example:在第一个例子中:

    • There are 2 non-arbiters and 1 arbiter for a total of 3 voting nodes.总共有3个投票节点,有2个非仲裁器和1个仲裁器。
    • The majority of voting nodes (1 plus half of 3, rounded down) is 2.大多数投票节点(1加3的一半,四舍五入)为2。
    • The number of non-arbiters (2) is equal to the majority of voting nodes (2), resulting in an implicit write concern of { w: 1 }.非仲裁器(2)的数量等于投票节点(2)的多数,导致隐式写关注点{w:1}
  • In the second example:在第二个例子中:

    • There are 4 non-arbiters and 1 arbiter for a total of 5 voting nodes.总共有5个投票节点,有4个非仲裁器和1个仲裁器。
    • The majority of voting nodes (1 plus half of 5, rounded down) is 3.大多数投票节点(1加5的一半,四舍五入)为3。
    • The number of non-arbiters (4) is greater than the majority of voting nodes (3), resulting in an implicit write concern of { w: "majority" }.非仲裁者(4)的数量大于多数投票节点(3),导致隐式写关注{ w: "majority" }

The { w: "majority" } default write concern provides a stronger durability guarantee in the event of an election, or if replica set members become unavailable.{ w: "majority" }默认写入关注点在选举或副本集成员不可用时提供了更强的持久性保证。

The { w: "majority" } write concern may impact performance since writes will only be acknowledged once a calculated majority of replica set members have executed and persisted the write to disk. { w: "majority" }写入关注点可能会影响性能,因为只有在计算出多数副本集成员执行并持久化磁盘写入后,才会确认写入。If your application relies on performance-sensitive writes, you can use the setDefaultRWConcern command to explicitly set the default write concern for improved performance at the cost of data durability guarantees. 如果应用程序依赖于对性能敏感的写操作,则可以使用setDefaultRWConcern命令显式设置默认写操作,以提高性能,同时牺牲数据持久性保证。You can also set the write concern at the individual operation level for performance-critical writes. 还可以在单个操作级别为性能关键型写入设置写入关注点。See your driver documentation for details.有关详细信息,请参阅驱动程序文档

mongosShutdownTimeoutMillisForSignaledShutdown Parameter参数

Starting in MongoDB 5.0, the new parameter mongosShutdownTimeoutMillisForSignaledShutdown specifies the time in milliseconds to wait for any ongoing database operations to complete before initiating a shutdown of mongos.从MongoDB 5.0开始,新参数mongosShutdownTimeoutMillisForSignaledShutdown指定在启动mongos关闭之前等待任何正在进行的数据库操作完成的时间(以毫秒为单位)。

Configurable zstd Compression Level可配置的zstd压缩级别

MongoDB 5.0 introduces the zstdCompressionLevel configuration file option which allows for configurable compression levels when blockCompressor is set to zstd.MongoDB 5.0引入了zstdCompressionLevel配置文件选项,当blockCompressor设置为zstd时,该选项允许配置压缩级别。

Lock-Free Read Operations无锁读取操作

Starting in MongoDB 5.0, the following read operations are not blocked when another operation holds an exclusive (X) write lock on the collection:从MongoDB 5.0开始,当另一个操作对集合持有独占(X)写锁时,以下读取操作不会被阻止:

When writing to a collection, mapReduce and aggregate hold an intent exclusive (IX) lock. 在写入集合时,mapReduceaggregate持有一个intent exclusive(IX)锁。Therefore, if an exclusive X lock is already held on a collection, mapReduce and aggregate write operations are blocked.因此,如果集合上已持有独占X锁,则会阻止mapReduceaggregate写入操作。

Schema Validation Failures Explained解释了模式验证失败

MongoDB 5.0 adds detailed explanations when a document fails schema validation.MongoDB 5.0在文档未能通过模式验证时添加了详细的解释。

Repair Option in validate Commandvalidate命令中的修复选项

Starting in MongoDB 5.0, the validate command and db.collection.validate() helper method have a new repair option for repairing a collection that has inconsistencies.从MongoDB 5.0开始,validate命令和db.collection.validate()助手方法有一个新的repair选项,用于修复存在不一致的集合。

The validate command and db.collection.validate() helper method also return a new repaired boolean value that is true if the collection was repaired.validate命令和db.collection.validate()助手方法还返回一个新的repaired布尔值,如果该集合已修复,则该值为true

validate Command Reports Document Schema Violationsvalidate命令报告文档架构冲突

Starting in MongoDB 5.0, validate and db.collection.validate() validates documents in a collection. 从MongoDB 5.0开始,validatedb.collection.validate()验证集合中的文档。The commands report if any schema validation rules are violated.如果违反任何架构验证规则,这些命令都会报告。

Repair Option in mongodmongod的维修选项

Starting in MongoDB 5.0, the --repair option for mongod validates the collections to find any inconsistencies and fixes them if possible, which avoids rebuilding the indexes. 从MongoDB 5.0开始,mongod--repair选项会验证集合,以发现任何不一致,并在可能的情况下修复它们,从而避免重建索引。See the --repair option for usage and limitations.有关用法和限制,请参阅--repair选项。

corruptRecords Field in Validation Output验证输出中的字段

Starting in MongoDB 5.0, the validate command and db.collection.validate() helper method return a new corruptRecords field that contains an array of RecordId values for corrupt documents.从MongoDB 5.0开始,validate命令和db.collection.validate()助手方法返回一个新的corruptRecords字段,该字段包含损坏文档的RecordId值数组。

maxValidateMemoryUsageMB Server Parameter服务器参数

Starting in MongoDB 5.0, the setParameter command has a new maxValidateMemoryUsageMB parameter, which sets the maximum memory usage for the validate command.从MongoDB 5.0开始,setParameter命令有一个新的maxValidateMemoryUsageMB参数,用于设置validate命令的最大内存使用量。

findChunksOnConfigTimeoutMS Server Parameter服务器参数

Starting in MongoDB 5.0, you can use the findChunksOnConfigTimeoutMS parameter to change the timeout for find operations on chunks.从MongoDB 5.0开始,可以使用findChunksOnConfigTimeoutMS参数更改块上查找操作的超时。

Database Profiler filter Option数据库探查器filter选项

Starting in MongoDB 5.0, you can set a filter option for the database profiler to determine which operations are profiled and logged. 从MongoDB 5.0开始,您可以为数据库探查器设置一个filter选项,以确定哪些操作被探查和记录。You can use the filter expression in place of the slowms and sampleRate profiler options.可以使用filter表达式代替slowmssampleRate探查器选项。

See:请参阅:

Log Changes to Database Profiler Settings记录对数据库探查器设置的更改

Starting in MongoDB 5.0 (also available starting in 4.4.2, 4.2.12, and 4.0.22), changes made to the database profiler level, slowms, sampleRate, or filter using the profile command or db.setProfilingLevel() wrapper method are recorded in the log file.从MongoDB 5.0开始(也可以从4.4.2、4.2.12和4.0.22开始),使用profile命令或db.setProfilingLevel()包装方法对数据库探查器levelslowmssampleRatefilter所做的更改将记录在日志文件中。

Independent Log Rotation for Server and Audit Logs服务器和审计日志的独立日志轮换

Starting in MongoDB 5.0, when auditing is enabled, you may now rotate the server and audit logs independently using the logRotate command. 从MongoDB 5.0开始,启用审计后,现在可以使用logRotate命令独立地旋转服务器和审计日志。Previously, logRotate would rotate the two logs together.之前,logRotate会将两个日志一起旋转。

remote Field in Slow Operation Logs慢速操作日志中的remote字段

Starting in MongoDB 5.0, slow operation log messages include a remote field specifying client IP address.从MongoDB 5.0开始,慢速操作日志消息包括一个指定客户端IP地址的remote字段。

remoteOpWaitMillis Log Field日志字段

Starting in MongoDB 5.0, you can use the remoteOpWaitMillis log field to obtain the wait time for results from shards.从MongoDB 5.0开始,可以使用remoteOpWaitMillis日志字段获取分片结果的等待时间。

resolvedViews Log Field for Slow Queries on Views用于对视图进行慢速查询的日志字段

Starting in MongoDB 5.0, log messages for slow queries on views include a resolvedViews field that contains the view details.从MongoDB 5.0开始,针对视图慢速查询的日志消息包括一个包含视图详细信息的resolvedViews字段。

Define Variables Using the let Option使用let选项定义变量

Starting in MongoDB 5.0, the following commands have a let option to define a list of variables. 从MongoDB 5.0开始,以下命令有一个let选项来定义变量列表。This allows you to improve command readability by separating the variables from the query text.这允许您通过将变量与查询文本分离来提高命令的可读性。

The update command also has a c field to define a list of variables.update命令还有一个c字段,用于定义变量列表。

Support for Username to LDAP DN Mapping by Default默认情况下支持用户名到LDAP DN的映射

Starting in MongoDB 5.0, the userToDNMapping configuration file option and the --ldapUserToDNMapping command line option for mongod / mongos and mongoldap now map the authenticated username as the LDAP DN by default if an empty mapping document (i.e. an empty string or empty array) is specified to the option. 从MongoDB 5.0开始,如果为选项指定了空映射文档(即空字符串或空数组),mongod/mongosmongoldapuserToDNMapping配置文件选项和--ldapUserToDNMapping命令行选项现在默认情况下将经过身份验证的用户名映射为LDAP DN。Previously, providing an empty mapping document would cause mapping to fail.以前,提供空映射文档会导致映射失败。

Additional dbStats Free Space Statistics其他dbStats可用空间统计信息

Starting in MongoDB 5.0, the dbStats command outputs these additional statistics:从MongoDB 5.0开始,dbStats命令输出以下附加统计信息:

serverStatus Output Change输出变化

serverStatus includes the following new fields in its output:在其输出中包括以下新字段:

Aggregation Metrics聚合度量
API Version MetricsAPI版本度量
Replication Metrics复制指标
Read Concern Counters阅读关注计数器
Number of Threaded Connections螺纹连接的数量
  • connections.threaded, which reports the number of incoming connections from clients that are assigned to threads that service client requests,它报告从客户端分配给为客户端请求提供服务的线程的传入连接数
Resharding Statistics重装统计
Service Executor Metrics服务执行器度量
  • network.serviceExecutors, which reports on the service executors that run operations for client requests,它报告为客户端请求运行操作的服务执行器
Cursor Metrics游标度量
  • metrics.cursor.moreThanOneBatch, which reports the total number of cursors that have returned more than one batch (additional batches are retrieved using the getMore command),它报告返回多个批的游标总数(使用getMore命令检索其他批)
  • metrics.cursor.totalOpened, which reports the total number of cursors that have been opened,它报告已打开的游标总数
Security Counter安全计数
Repl
  • repl now includes a primaryOnlyServices document that contains additional information about services that only run on replica set primaries.现在包括一个primaryOnlyServices文档,其中包含有关仅在副本集Primary上运行的服务的附加信息。

Plan Cache Debug Info Size Limit计划缓存调试信息大小限制

Starting in MongoDB 5.0 (and 4.4.3, 4.2.12, 4.0.23, and 3.6.23), the plan cache will save full plan cache entries only if the cumulative size of the plan caches for all collections is lower than 0.5 GB. 从MongoDB 5.0(以及4.4.3、4.2.12、4.0.23和3.6.23)开始,只有当所有集合的计划缓存的累积大小小于0.5 GB时,计划缓存才会保存完整的计划缓存项。When the cumulative size of the plan caches for all collections exceeds this threshold, additional plan cache entries are stored without certain debug information.当所有集合的计划缓存的累积大小超过此阈值时,将存储其他计划缓存项,而不存储特定的调试信息。

The estimated size in bytes of a plan cache entry is available in the output of $planCacheStats.计划缓存项的估计大小(以字节为单位)可在$planCacheStats的输出中获得。

Closure of Inactive Cursors Opened Within a Session关闭会话中打开的非活动游标

Starting in MongoDB 5.0 (and 4.4.8), cursors created within a client session close when the corresponding server session ends with the killSessions command, if the session times out, or if the client has exhausted the cursor. 从MongoDB 5.0(和4.4.8)开始,当相应的服务器会话killSessions命令结束时,如果会话超时,或者如果客户端耗尽了游标,则在客户端会话中创建的游标将关闭。See Iterate a Cursor in mongosh.请参见mongosh中迭代游标

New validateDBMetadata Command新的validateDBMetadata命令

MongoDB 5.0 adds the validateDBMetadata command. MongoDB 5.0添加了validateDBMetadata命令。The validateDBMetadata command checks that the stored metadata of a database or a collection is valid within a particular API version.validateDBMetadata命令检查存储的数据库或集合的元数据在特定API版本内是否有效。

Platform Support平台支撑

Minimum Microarchitecture最小微体系结构

MongoDB 5.0 introduces the following minimum microarchitecture requirements:MongoDB 5.0引入了以下最低微体系结构要求:

CPUMinimum Supported Microarchitecture最小支持微体系结构
Intel x86_64

MongoDB 5.0 requires one of:MongoDB 5.0需要以下选项之一:

  • Intel Sandy Bridge or later Core processor, or英特尔Sandy Bridge或更高版本的核心处理器,或
  • Intel Tiger Lake or later Celeron or Pentium processor.英特尔老虎湖或更高版本的赛扬或奔腾处理器。
AMD x86_64MongoDB 5.0 requires AMD Bulldozer or later.
ARM arm64MongoDB 5.0 requires ARMv8.2-A or later.

MongoDB v5.0 is not supported on x86_64 or arm64 platforms that do not meet these minimum microarchitecture requirements.不满足这些最低微体系结构要求的x86_64arm64平台不支持MongoDB v5.0。

See x86_64 Platform Support for more information.有关更多信息,请参阅x86_64平台支持

Removed Platforms移除的平台

MongoDB 5.0 removes support for the following platforms:MongoDB 5.0取消了对以下平台的支持:

  • macOS 10.13
  • RHEL 7 / CentOS 7 / Oracle 7 on the PPC64LE architecture
  • SLES 12 on the s390x architecture
  • Ubuntu 18.04 on the PPC64LE and s390x architectures

See Supported Platforms for the full list of platforms and architectures supported in MongoDB 5.0.有关MongoDB 5.0中支持的平台和体系结构的完整列表,请参阅支持的平台

Changes Affecting Compatibility影响兼容性的更改

Some changes can affect compatibility and may require user actions. 某些更改可能会影响兼容性,并可能需要用户操作。For a detailed list of compatibility changes, see Compatibility Changes in MongoDB 5.0.有关兼容性更改的详细列表,请参阅MongoDB 5.0中的兼容性更改

Upgrade Procedures升级程序

Important重要
Feature Compatibility Version功能兼容性版本

To upgrade to MongoDB 5.0 from a 4.4 deployment, the 4.4 deployment must have featureCompatibilityVersion set to 4.4. 要从4.4部署升级到MongoDB 5.0,4.4部署必须将featureCompatibilityVersion设置为4.4To check the version:要检查版本,请执行以下操作:

db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )

To upgrade to MongoDB 5.0, refer to the upgrade instructions specific to your MongoDB deployment:要升级到MongoDB 5.0,请参阅特定于MongoDB部署的升级说明:

If you need guidance on upgrading to 5.0, MongoDB offers major version upgrade services to help ensure a smooth transition without interruption to your MongoDB application.如果您需要升级到5.0的指导,MongoDB提供主要的版本升级服务,以帮助确保顺利过渡到MongoDB应用程序,而不会中断。

Download下载

To download MongoDB 5.0, go to the MongoDB Download Center.要下载MongoDB 5.0,请访问MongoDB下载中心

Tip提示
See also: 参阅:

Known Issues已知问题

In Version所在版本Issues问题Status状态
5.0.0SERVER-58171: A Time Series collection's granularity parameter cannot be modified after the collection is created.:创建时间序列集合后,无法修改该集合的granularity(粒度)参数。Fixed in 5.0.1在5.0.1中修复
5.0.0SERVER-58392: An ongoing resharding operation may prevent a backup or restore operation from succeeding.:正在进行的重新存储操作可能会阻止备份或还原操作成功。Unresolved待解决

Report an Issue报告一个问题

To report an issue, see https://github.com/mongodb/mongo/wiki/Submit-Bug-Reports for instructions on how to file a JIRA ticket for the MongoDB server or one of the related projects.要报告问题,请参阅https://github.com/mongodb/mongo/wiki/Submit-Bug-Reports以了解有关如何为MongoDB服务器或其中一个相关项目提交JIRA票证的说明。

←  5.1 ChangelogCompatibility Changes in MongoDB 5.0 →