Release Notes for MongoDB 5.1
On this page
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.
Patch Releases
5.1.1 - December 9, 2021
Issues fixed:
SERVER-61633 Resharding's RecipientStateMachine doesn't join thread pool for ReshardingOplogFetcher, leading to server crash at shutdown
SERVER-61483 Resharding coordinator fails to recover abort decision on step-up, attempts to commit operation as success, leading to data inconsistency
SERVER-61482 Updates to config.reshardingOperations wait for PrimaryOnlyService to be rebuilt while holding oplog slot, stalling replication on config server indefinitely
SERVER-61304 Unable to use --use-system-{pcre,boost,...} with r5.1.0
SERVER-51329 Unexpected non-retryable error when shutting down a mongos server
5.1.0 - Nov 9, 2021
The rest of this page provides the 5.1.0 release notes:
Aggregation
New Aggregation Stages
MongoDB 5.1 introduces the following aggregation stages:
Stage | Description |
---|---|
Creates new documents in a sequence of documents where values in
a specified field are missing. | |
Returns literal documents from input expressions. |
New Aggregation Operators
MongoDB 5.1 introduces the following aggregation operators:
$geoNear accepts let-bound
variables
Starting in MongoDB 5.1, the near
parameter in the $geoNear
aggregation stage supports the let option and
bound let option.
$lookup and $graphLookup with sharded collections
Starting in MongoDB 5.1,
the $lookup
and $graphLookup
aggregation stages
support sharded collections in the from
parameter.
In previous versions of MongoDB, $lookup
and $graphLookup
only allowed for unsharded from
collections.
General Aggregation Improvements
Starting in MongoDB 5.1, $dateSubtract
and
$dateAdd
report an error when an overflow is detected for
amount
values.
Time Series Collections
Geo Indexing for Time Series collections
Starting in MongoDB 5.1, you can use geo indexes on the metaField
of time
series collections.
Updates and Deletes
Starting in MongoDB 5.1, time series collections support update and delete operations with limitations.
Sharded Time Series Collections
MongoDB 5.1 provides support for sharded time series collections.
See:
Slot-Based Query Execution Engine
Starting in MongoDB 5.1, a new query execution engine is used for eligible queries. If the slot based query execution engine is used, new fields are included in the query explain plan output.
The new query execution engine is used if possible.
If the new query execution engine is used, new fields are included in the query explain plan output.
Set Slot-Based Query Execution Plan Cache Size
You can set the size of the plan cache for the new query engine with the
planCacheSize
parameter.
Increasing the plan cache size adds more cached query shapes for the query planner. This can improve query performance, but increases memory usage.
Change Streams
Starting in MongoDB 5.1, change streams are optimized, providing more efficient resource utilization and faster execution of some aggregation pipeline stages.
Indexes
Starting in MongoDB 5.1, you can use the collMod
database
command to add the expireAfterSeconds
option to an existing
single-field non-TTL index.
Platform Support
Starting in MongoDB 5.1.2 the following platforms are no longer supported.
Community Edition
RHEL-72-s390x
General Improvements
Metadata Option Added for validate
Command
Starting in MongoDB 5.1 (and MongoDB 5.0.4), the validate
command and the db.collection.validate()
helper method have a
new metadata option that quickly
validates collections and detects invalid index options.
serverStatus
Output Change
serverStatus
includes the following new fields in its
output:
- Aggregation Metrics
metrics.operatorCounters.match
A document which indicates how often match expressions ran.
- Opcode Counters
opcounters.deprecated
A count of how often deprecated opcodes run.
- Resharding Statistics
Extra Logging Fields for Slow Queries with getMore
Command
Starting in MongoDB 5.1, when a getMore
command is logged
as a slow query, the queryHash and planCacheKey fields are added
to the slow query log message and the
profiler log message.
Schema Validation Errors Contain Description Field
Starting in MongoDB 5.1, when a document fails schema validation, MongoDB includes the validation title
and description
in the error response. You can use these fields to
provide an explanation of the validation when the rules are not
immediately clear, such as when using regular expressions.
For an example, see Specify JSON Schema Validation.
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.
storeFindAndModifyImagesInSideCollection
Parameter
Starting in MongoDB 5.1, the
storeFindAndModifyImagesInSideCollection
parameter
determines whether the temporary documents required for retryable findAndModify
commands are stored in
the side collection (config.image_collection
).
Sharded Clusters
mongod
Sharded Cluster And Config Server Changes
Starting in MongoDB 5.1, when starting a mongod
with the
--configsvr
option you must also
specify a --replSet
.
Starting in MongoDB 5.1, when starting a mongod
with the
--shardsvr
option you must also
specify a --replSet
.
Security
SELinux
Starting in MongoDB 5.1, there is a new SE Linux Policy for:
MongoDB Enterprise Server
MongoDB Community Edition Server
running on Red Hat Linux. The SELinux policy is for use with default
installations using rpm
installer packages.
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.