Compatibility Changes in MongoDB 5.1MongoDB 5.1中的兼容性更改

On this page本页内容

Important重要

MongoDB 5.1 is a rapid release and is only supported for MongoDB Atlas. MongoDB 5.1是一个快速版本,只支持MongoDB Atlas。MongoDB 5.1 is not supported for use on-premises. MongoDB 5.1不支持在本地使用。For more information, see MongoDB Versioning.有关更多信息,请参阅MongoDB版本控制

The following 5.1 changes can affect compatibility with older versions of MongoDB.以下5.1更改可能会影响与旧版本MongoDB的兼容性。

Removed Operators被删除的运算符

Starting in MongoDB 5.1, these operators are removed:从MongoDB 5.1开始,删除以下运算符:

Removed Operator删除的运算符Alternative可供替代的
$commentcursor.comment()
$explaincursor.explain()
$hintcursor.hint()
$maxcursor.max()
$maxTimeMScursor.maxTimeMS()
$mincursor.min()
$orderbycursor.sort()
$querySee Cursor Methods
$returnKeycursor.returnKey()
$showDiskLoccursor.showRecordId()
db.getLastError()See Legacy Opcodes Removed
db.getLastErrorObj()See Legacy Opcodes Removed
getLastErrorSee Legacy Opcodes Removed

Removed Parameters删除的参数

MongoDB 5.1 removes the following server parameters:MongoDB 5.1删除了以下服务器参数:

Removed Parameters删除的参数Description描述
--tlsFIPSMode

This option is removed from the MongoDB Community Edition. 此选项已从MongoDB社区版中删除。It is available in MongoDB Enterprise edition.它在MongoDB企业版中提供。

FIPS was not a supported feature in MongoDB Community Edition. FIPS在MongoDB社区版中不受支持。If your installation made use of FIPS anyway, you will need to reconfigure your TLS/SSL connections before upgrading.如果您的安装使用了FIPS,那么在升级之前,您需要重新配置TLS/SSL连接

MongoDB 5.1 removes the following parameters from the mongo shell:MongoDB 5.1从mongo shell中删除以下参数:

Removed Parameters被删除的参数Description描述
--useLegacyWriteOpsThe ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is removed. 删除了使用OP_INSERT、OP_UPDATE和OP_DELETE的功能。The shell will only use OP_MSG write commands.shell将只使用OP_MSG write命令。
--writeModeThe ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is removed. 删除了使用OP_INSERT、OP_UPDATE和OP_DELETE的功能。The shell will only use OP_MSG write commands.shell将只使用OP_MSG write命令。
--readModeThe ability to use OP_QUERY legacy find is removed. 删除了使用OP_QUERY legacy find的功能。The shell will only use OP_MSG find commands.shell将只使用OP_MSG find命令。
--rpcProtocolsSupport for the OP_QUERY RPC protocol is removed. 对OP_QUERY RPC协议的支持已被删除。The shell will always use the OP_MSG RPC protocol.shell将始终使用OP_MSG RPC协议。

Aggregation聚集

$setWindowFields Transactions and Snapshot Read Concern事务和快照读取问题

Starting in MongoDB 5.1 (and 5.0.4), the $setWindowFields stage cannot be used within transactions or with "snapshot" read concern.从MongoDB 5.1(和5.0.4)开始,$setWindowFields阶段不能在事务中使用,也不能与"snapshot"读取关注点配合使用。

Replica Sets复制集

Assert Cluster Wide Write Concern is Set When Starting or Adding Shard启动或添加分片时设置了断言群集范围的写入问题

Starting in MongoDB 5.1, when starting, restarting or adding a shard server with sh.addShard() the Cluster Wide Write Concern (CWWC) must be set.从MongoDB 5.1开始,在使用sh.addShard()启动、重新启动或添加分片服务器时,必须设置集群范围的写入关注点(CWWC)

If the CWWC is not set and the shard is configured such that the default write concern is { w : 1 } the shard server will fail to start or be added and returns an error.如果未设置CWWC,并且已将分片配置为默认写入关注点{w:1},则分片服务器将无法启动或添加,并返回错误。

See default write concern calculations for details on how the default write concern is calculated.有关如何计算默认写入关注点的详细信息,请参阅默认写入关注点计算

rs.reconfig Cluster Wide Write Concern Validation集群范围的写关注点验证

Starting in MongoDB 5.1, you must set the Cluster Wide Write Concern (CWWC) prior to issuing any reconfigs that would otherwise change the default write concern of the new replica set member.从MongoDB 5.1开始,必须先设置集群范围的写入关注点(CWWC),然后再进行任何reconfigs,否则会更改新副本集成员的默认写关注点

Arbiters

Arbiters are not supported with quarterly rapid releases releases. 季度快速发布不支持。If your deployment includes arbiters, only use LTS releases.如果部署中包含仲裁器,则只使用LTS版本。

Time Series Collections时间序列集合

Warning警告

If you create a sharded time series collection in MongoDB 5.1 or greater, downgrading to a version older than MongoDB 5.0.4 will result in data loss.如果在MongoDB 5.1或更高版本中创建分片时间序列集合,降级到MongoDB 5.0.4之前的版本将导致数据丢失。

Before downgrading to a version older than 5.0.4, drop all sharded time series collections.在降级到早于5.0.4的版本之前,请删除所有分片时间序列集合。

General Changes一般变化

$regex Find Queries No Longer Ignore Invalid Regex查找查询不再忽略无效的正则表达式

Starting in MongoDB 5.1, invalid $regex options options are no longer ignored. 从MongoDB 5.1开始,无效的$regex选项将不再被忽略。This change makes $regex options more consistent with the use of $regex in the aggregate command and projection queries.此更改使$regex选项与在aggregate命令和投影查询中使用$regex更加一致。

$regex Schema Validation Error Behavior模式验证错误行为

Starting in MongoDB 5.1, if a collection has schema validation rules that contain invalid $regex options the server:从MongoDB 5.1开始,如果集合的架构验证规则包含无效的$regex选项,则服务器:

  • Prevents all insert and update operations until the schema validation rules containing the invalid regex pattern are modified with the collMod command.阻止所有插入和更新操作,直到使用collMod命令修改包含无效正则表达式模式的架构验证规则。
  • Writes a warning error to the mongod log file.将警告错误写入mongod日志文件。

FIPS Mode Defaults SCRAM-SHA-1 Authentication to OffFIPS模式将紧急停堆-SHA-1身份验证默认为关闭

Starting in MongoDB 5.1, instances running in FIPS mode have the SCRAM-SHA-1 authentication mechanism disabled by default. 从MongoDB 5.1开始,在FIPS模式下运行的实例默认禁用了SCRAM-SHA-1身份验证机制You can enable the SCRAM-SHA-1 authentication mechanism with the setParameter.authenticationMechanisms command.可以使用setParameter.authenticationMechanisms命令启用SCRAM-SHA-1身份验证机制

This change will not affect drivers which target MongoDB setFeatureCompatibilityVersion 4.0+.此更改不会影响以MongoDB setFeatureCompatibilityVersion 4.0+为目标的驱动程序。

$mod Error Behavior错误行为

Starting in MongoDB 5.1 (and 5.0.4 and 4.4.10), the $mod operator returns an error if the divisor or remainder values evaluate to certain values. 从MongoDB 5.1(以及5.0.4和4.4.10)开始,如果divisor(除数)或remainder(余数)值计算为特定值,$mod运算符将返回一个错误。See $mod behavior.

Legacy Opcodes Removed删除旧操作码

MongoDB drivers have used OP_MSG instead of OP_QUERY and the other legacy opcodes since MongoDB v3.6.MongoDB驱动程序使用了OP_MSG,而不是OP_QUERY,以及自MongoDB v3.6以来的其他遗留操作码。

This release removes support for the following legacy opcodes:此版本取消了对以下旧操作码的支持:

To avoid disruption due to the removal of these op codes, please upgrade your driver to the latest version.为避免因删除这些操作码而中断,请将驱动程序升级至最新版本。

mongod will close the connection and will not respond to:将关闭连接,并且不会响应:

mongod will return an error for:将返回以下内容的错误:

The OP_QUERY RPC protocol may be used with the following commands:OP_QUERY RPC协议可与以下命令一起使用:

  • _isSelf
  • authenticate
  • buildinfo
  • buildInfo
  • hello
  • ismaster
  • isMaster
  • saslContinue
  • saslStart

OP_QUERY will return an error if it is used for a find operation. 如果用于查找操作,将返回错误。All other commands will be rejected if issued as OP_QUERY.如果作为OP_QUERY发出,所有其他命令将被拒绝。

If you attempt to connect to a MongoDB 3.4, or older, mongod instance with a MongoDB 5.1, or newer, mongo shell, you will receive an error message like the following:如果您试图使用MongoDB 5.1或更新版本的mongo shell连接到MongoDB 3.4或更早版本的mongod实例,您将收到如下错误消息:

// Reformated for clarity. The message appears on a single line.
Connection handshake failed. Is your mongod 3.4 or older?
:: caused by :: network error while attempting to run command
'isMaster' on host '127.0.0.1:27017'

Platform Support平台支撑

Starting in MongoDB 5.1.2 the following platforms are no longer supported.从MongoDB 5.1.2开始,以下平台不再受支持。

Community Edition社区版

  • RHEL-72-s390x

5.1 Feature Compatibility5.1功能兼容性

Some features in 5.1 require the 5.1 binaries and the featureCompatibilityVersion (fCV) must also be set to 5.1. 5.1中的某些功能需要5.1二进制文件,功能兼容性版本(fCV)也必须设置为5.1。These features include:这些特点包括:

←  Release Notes for MongoDB 5.15.1 Changelog →