Docs Menu

Compatibility Changes in MongoDB 5.1

On this page

  • Removed Operators
  • Removed Parameters
  • Aggregation
  • Replica Sets
  • Time Series Collections
  • General Changes
  • Platform Support
  • 5.1 Feature Compatibility
Important

MongoDB 5.1 is a rapid release and is only supported for MongoDB Atlas. MongoDB 5.1 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.

Starting in MongoDB 5.1, these operators are removed:

Removed Operator
Alternative
$comment
$explain
$hint
$max
$maxTimeMS
$min
$orderby
$query
$returnKey
$showDiskLoc
db.getLastError()
db.getLastErrorObj()
getLastError

MongoDB 5.1 removes the following server parameters:

Removed Parameters
Description

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.

Starting in MongoDB 5.1 (and 5.0.4), the $setWindowFields stage cannot be used within transactions or with "snapshot" read concern.

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.

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 are not supported with quarterly rapid releases releases. If your deployment includes arbiters, only use LTS releases.

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.

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.

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.

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+.

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.

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:

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:

// 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'

Starting in MongoDB 5.1.2 the following platforms are no longer supported.

  • RHEL-72-s390x

Some features in 5.1 require the 5.1 binaries and the featureCompatibilityVersion (fCV) must also be set to 5.1. These features include:

←  Release Notes for MongoDB 5.15.1 Changelog →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.