Navigation

Compatibility Changes in MongoDB 4.2 (Development Series 4.1.x)

MongoDB 4.2 is currently in development as part of the 4.1 development series.

Warning

While the 4.1-dev-series are available, these versions of MongoDB are for testing purposes only and not for production use.

Removal of MMAPv1 Storage Engine

MongoDB 4.2 removes support for the deprecated MMAPv1 storage engine.

If your 4.0 deployment uses MMAPv1, you must change the deployment to WiredTiger Storage Engine before upgrading to MongoDB 4.2. For details, see:

MMAPv1 Specific Configuration Options

MongoDB removes the following MMAPv1 specific configuration options:

Configuration File Setting Command-line Option
storage.mmapv1.journal.commitIntervalMs  
storage.mmapv1.journal.debugFlags mongod --journalOptions
storage.mmapv1.nsSize mongod --nssize
storage.mmapv1.preallocDataFiles mongod --noprealloc
storage.mmapv1.quota.enforced mongod --quota
storage.mmapv1.quota.maxFilesPerDB mongod --quotaFiles
storage.mmapv1.smallFiles mongod --smallfiles
storage.repairPath mongod --repairpath
replication.secondaryIndexPrefetch mongod --replIndexPrefetch

MMAPv1 Specific Parameters

MongoDB removes the following MMAPv1 parameters:

  • newCollectionsUsePowerOf2Sizes
  • replIndexPrefetch

MMAPv1 Specific Command

MongoDB removes the MMAPv1 specific touch command.

MMAPv1 Specific Options for Commands and Methods

MongoDB removes the MMAPv1 specific options:

Removed Commands and Methods

Remove Support for the group Command

Starting in version 4.2, MongoDB removes the group command (deprecated since version 3.4) and its mongo shell helper db.collection.group().

Use db.collection.aggregate() with the $group stage instead.

Remove Support for the eval Command

Starting in version 4.2, MongoDB removes the eval command. eval command has been deprecated since version 3.0.

The associated MongoDB 4.2 mongo shell methods db.eval() and db.collection.copyTo() can only be run when connected to MongoDB 4.0 or earlier.

Remove Support for the copydb and clone Commands

Starting in version 4.2, MongoDB removes the deprecated copydb command and clone command.

The corresponding mongo shell helpers db.copyDatabase() and db.cloneDatabase() can only be run when connected to MongoDB 4.0 or earlier.

As an alternative, users can use mongodump and mongorestore or write a script using the drivers.

Remove Support for the parallelCollectionScan Command

Starting in version 4.2, MongoDB removes the parallelCollectionScan command.

Remove maxScan

MongoDB removes the deprecated option maxScan for the find command and the mongo shell helper cursor.maxScan(). Use either the maxTimeMS option for the find command or the helper cursor.maxTimeMS() instead.

Remove Support for the geoNear Command

Starting in version 4.2, MongoDB removes the geoNear command. Use the $geoNear aggregation stage instead.

The options for $geoNear are similar to the removed geoNear command with the following exceptions:

  • The removed geoNear command includes in its output a field named dis that included the distance information.

    For the $geoNear stage, specify the distance field name in distanceField.

  • The removed geoNear command accepts a boolean value for the includeLocs option to include the loc field.

    For the $geoNear stage, specify the location field name in includeLocs.

  • The removed geoNear command includes the avgDistance and maxDistance of the returned results.

    You can use the aggregation pipeline to return the avgDistance and maxDistance as well. Specifically, after the $geoNear stage, include a $group stage to calculate the avgDistance and maxDistance:

    db.places.aggregate([
       { $geoNear: { near: <...>, distanceField: "dis", includeLocs: "loc", spherical: true, ... } },
       { $group: { _id: null, objectsLoaded: { $sum: 1 }, maxDistance:
             { $max: "$dis" }, avgDistance: { $avg: "$dis" } } }
    ])
    

Remove Support for the repairDatabase Command

Starting in version 4.2, MongoDB removes the repairDatabase command and its mongo shell helper db.repairDatabase().

As alternatives:

General Changes

4.2 Feature Compatibility

Some features in 4.2 require not just the 4.2 binaries but the featureCompatibilityVersion (fCV) set to 4.2. These features include:

  • Removal of Index Key Limit for MongoDB versions with fCV set to 4.2+. In concert with the removal of this limit, the failIndexKeyTooLong parameter has no effect for MongoDB versions with fCV set to 4.2+ and only applies for MongoDB 2.6 through MongoDB versions with fCV set to "4.0" or earlier.
  • Removal of Index Name Length for MongoDB versions with fCV set to 4.2+.