- Release Notes >
- Release Notes for MongoDB 5.1 >
- Compatibility Changes in MongoDB 5.1
Compatibility Changes in MongoDB 5.1¶
On this page
Important
MongoDB 5.0 is a rapid release and is only supported for MongoDB Atlas. MongoDB 5.0 is not supported for use on-premises. For more information, see MongoDB Versioning.
The following 5.1 changes can affect compatibility with older versions of MongoDB.
Removed Operators¶
Starting in MongoDB 5.1, these operators are removed:
Removed Operator | Alternative |
---|---|
$comment | cursor.comment() |
$explain | cursor.explain() |
$hint | cursor.hint() |
$max | cursor.max() |
$maxTimeMS | cursor.maxTimeMS() |
$min | cursor.min() |
$orderby | cursor.sort() |
$query | See Cursor Methods |
$returnKey | cursor.returnKey() |
$showDiskLoc | cursor.showRecordId() |
db.getLastError() |
See Legacy Opcodes Removed |
db.getLastErrorObj() |
See Legacy Opcodes Removed |
getLastError |
See Legacy Opcodes Removed |
Removed Parameters¶
MongoDB 5.1 removes the following server parameters:
Removed Parameters | Description |
---|---|
--tlsFIPSMode |
This option is removed from the MongoDB Community Edition. It is available in `MongoDB Enterprise`_ edition. FIPS was not a supported feature in MongoDB Community Edition. If your installation made use of FIPS anyway, you will need to reconfigure your TLS/SSL connections before upgrading. |
MongoDB 5.1 removes the following parameters from the
mongo
shell:
Removed Parameters | Description |
---|---|
--useLegacyWriteOps |
The ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is removed. The shell will only use OP_MSG write commands. |
--writeMode |
The ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is removed. The shell will only use OP_MSG write commands. |
--readMode |
The ability to use OP_QUERY legacy find is removed. The shell will only use OP_MSG find commands. |
--rpcProtocols |
Support for the OP_QUERY RPC protocol is removed. The shell will always use the OP_MSG RPC protocol. |
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.
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.
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.
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.
Arbiters¶
Arbiters are not supported with quarterly rapid releases releases. If your deployment includes arbiters, only use LTS releases.
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.
Before downgrading to a version older than 5.0.4, drop all sharded time series collections.
General Changes¶
$regex
Find Queries No Longer Ignore Invalid Regex¶
Starting in MongoDB 5.1, invalid $regex options
options are no longer ignored. This change makes
$regex options
more consistent with
the use of $regex
in the aggregate
command and
projection queries.
$regex
Schema Validation Error Behavior¶
Starting in MongoDB 5.1, if a collection has
schema validation
rules that contain invalid $regex options
the server:
- Prevents all insert and update operations until the schema validation
rules containing the invalid regex pattern are modified with the
collMod
command. - Writes a warning error to the
mongod
log file.
FIPS Mode Defaults SCRAM-SHA-1 Authentication to Off¶
Starting in MongoDB 5.1, instances running in FIPS mode have the SCRAM-SHA-1 authentication mechanism disabled by default. You can enable the SCRAM-SHA-1 authentication mechanism with the setParameter.authenticationMechanisms command.
This change will not affect drivers which target 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. 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.
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:
- OP_GET_MORE
- OP_QUERY legacy find
The OP_QUERY RPC protocol may be used with the following commands:
_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.
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: