All Products
Search
Document Center

ApsaraDB for MongoDB:ApsaraDB for MongoDB major version upgrade

Last Updated:Nov 20, 2024

ApsaraDB for MongoDB supports the upgrades of MongoDB major versions. ApsaraDB for MongoDB supports a variety of instance architectures and versions. Before you upgrade an instance, we recommend that you familiarize yourself with the MongoDB major versions available for upgrade and their compatibility changes.

MongoDB major versions available for upgrades

  • You can perform a major version upgrade in the ApsaraDB for MongoDB console. The following table lists the available MongoDB major versions and describes whether the versions are supported in different instance architectures and versions.

    Architecture

    Category

    Current major version

    Major version available for upgrade

    Standalone instance

    General-purpose instance that uses cloud disks

    MongoDB 4.0

    No new major version is available for upgrade.

    General-purpose instance that uses cloud disks

    MongoDB 3.4

    You cannot upgrade the major version of the instance.

    To upgrade the major version of an instance, you can create an instance and replace the old instance with the new instance. For information about how to create a standalone instance, see Create a standalone instance.

    Replica set instance

    Dedicated instance that uses cloud disks

    MongoDB 7.0

    No new major version is available for upgrade.

    MongoDB 6.0

    MongoDB 7.0

    MongoDB 5.0

    MongoDB 6.0

    MongoDB 4.4

    MongoDB 5.0

    • General-purpose instance that uses local disks

    • Dedicated instance that uses local disks

    • Dedicated host instance

    MongoDB 4.2

    You cannot upgrade the major version of the instance.

    To upgrade the major version of an instance, you can create an instance and replace the old instance with the new instance. For more information about how to create a replica set instance, see Create a replica set instance.

    MongoDB 4.0

    MongoDB 4.2

    MongoDB 3.4

    • MongoDB 4.0

    • MongoDB 4.2

    MongoDB 3.2

    MongoDB 3.0

    Sharded cluster instance

    Dedicated instance that uses cloud disks

    MongoDB 7.0

    No new major version is available for upgrade.

    MongoDB 6.0

    MongoDB 7.0

    MongoDB 5.0

    MongoDB 6.0

    MongoDB 4.4

    MongoDB 5.0

    • General-purpose instance that uses local disks

    • Dedicated instance that uses local disks

    • Dedicated host instance

    MongoDB 4.2

    You cannot upgrade the major version of the instance.

    To upgrade the major version of an instance, you can create an instance and replace the old instance with the new instance. For more information about how to create a sharded cluster instance, see Create a sharded cluster instance.

    MongoDB 4.0

    MongoDB 4.2

    MongoDB 3.4

    • MongoDB 4.0

    • MongoDB 4.2

    MongoDB 3.2

    MongoDB 3.0

  • To upgrade the major version of an instance across instance architectures or storage classes, create an instance running a major version to which you want to upgrade and then use Data Transmission Service (DTS) to migrate data from the source instance to the created instance. For more information about how to create an instance, see Create an instance.

    For more information about how to migrate data, see the following topics:

Compatibility changes of MongoDB major versions

The following table describes the compatibility changes of MongoDB major versions.

Important
  • When you upgrade the major version of an instance, the instance must be in the Running state. For more information about how to upgrade the major version of an instance, see Upgrade the major version of an instance.

  • Major version downgrade is not supported by instances.

  • Instances that run MongoDB 4.0 or later support the features of MongoDB 3.6. To use the features of MongoDB 3.6, upgrade your instance to MongoDB 4.0 or later.

  • The compatibility changes described in this topic involve only MongoDB kernel changes. Changes to instance management features are not described.

Major engine version

Compatibility change

MongoDB 7.0

  • When you upgrade the major version of an instance to MongoDB 7.0, no compatibility issues exist.

  • If you want to downgrade an instance from MongoDB 7.0 to an earlier major version, you must remove the features supported by MongoDB 7.0, such as the following items:

    • Remove all columnar indexes.

    • Unregister the cluster parameters specified by the setClusterParameter command. For more information, see setClusterParameter.

    • Remove all collections that are created with the encryptedFields option.

    • Remove all compound wildcard indexes.

For more information about MongoDB 7.0, see Compatibility Changes in MongoDB 7.0.

MongoDB 6.0

  • If the size of data involved in an aggregation pipeline exceeds 100 MB, the data is written to temporary disk storage by default. To change this default setting, set the allowDiskUseByDefault parameter to false.

    If you use a version earlier than MongoDB 6.0, you must use the { allowDiskUse: true } syntax to allow writing data to temporary disk storage.

  • If you specify * in the dropIndexes command, you can drop all indexes except the _id index and the last remaining shard key index. For more information, see dropIndexes.

  • The mongo shell is deprecated. Use mongosh instead.

  • Operators, such as $explain, $hint, $max, and $maxTimeMS, are deprecated.

  • If the expireAfterSeconds parameter is set to NaN (or 0) for a time to live (TTL) index, expired documents may be evicted immediately.

  • The SCRAM-SHA-1 mechanism is deprecated.

  • The reIndex command and the corresponding reIndex() method are deprecated.

For more information about MongoDB 6.0, see Compatibility Changes in MongoDB 6.0.

MongoDB 5.0

  • The read concern level of secondary nodes is changed from available to local. For more information, see Read Concern.

  • The default write concern is changed from 1 to majority.

  • The db.collection.ensureIndex() method is deprecated. You can use the db.collection.createIndex() method instead.

  • The parameters of the saslStart and saslContinue commands are strictly validated and not supported by the MongoDB driver for Go (mgo). The saslContinue command contains only the conversationId and payload parameters, whereas mgo has an additional mechanism parameter. For more information, visit mgo.

  • The geoSearch command is deprecated.

For more information about MongoDB 5.0, see Compatibility Changes in MongoDB 5.0.

MongoDB 4.4

  • The force option is deprecated from the compact command. For more information, see compact.

  • The geoSearch command is deprecated. For more information, see geoSearch.

  • You can create indexes on both the primary and secondary databases to reduce the latency caused by index creation. This way, when an index is being created, the secondary database can still access the latest data.

For more information about MongoDB 4.4, see Compatibility Changes in MongoDB 4.4.

MongoDB 4.2

  • The geoNear command is deprecated. Use the $geoNear (aggregation) command instead. For more information, see $geoNear.

  • The repairDatabase command is deprecated.

  • The cloneCollection command is deprecated. Use the mongoexport and mongoimport tools instead. For more information, see mongoexport, and mongoimport.

  • The afterClusterTime read concern option is deprecated. For more information, see Read Operations and afterClusterTime.

  • Drivers that are compatible with MongoDB 4.2 or later enable retryable writes by default. For more information, see Retryable Writes.

  • The group, copydb, and clone commands are deprecated.

For more information about MongoDB 4.2, see Compatibility Changes in MongoDB 4.2.

MongoDB 4.0

  • The reIndex command obtains a global exclusive (W) lock and blocks other operations until an index is rebuilt. For more information, see reIndex.

  • The copydb and clone commands are deprecated.

For more information about MongoDB 4.0, see Compatibility Changes in MongoDB 4.0.

MongoDB 3.6

  • The use of the aggregate command without the cursor option to return a single document is deprecated. Unless you include the explain option, you must specify the cursor option. You can use the cursor option to specify a batch size. For more information about the aggregate command, see aggregate.

  • In MongoDB 3.6 and later versions, the query for $type: "array" returns documents where the field itself is an array. In versions earlier than MongoDB 3.6, the query for $type: "array" returns documents where the field itself is an array that contains at least one element of the array type. For more information about $type, see $type.

  • The following changes to array ordering are added:

    • The optional sort option is added to the find command to provide the ordering of results. For more information about the find command, see find.

    • $sort in the $sort(aggregation) stage has a memory limit of 100 MB. For more information, see $sort (aggregation).

  • If an update operation involves multiple fields, the fields are added in lexicographical order. For more information, see $set.

  • The snapshot query option is deprecated.

For more information about MongoDB 3.6, see Compatibility Changes in MongoDB 3.6.

MongoDB 3.4

  • The group command is deprecated. Use the db.collection.aggregate() or db.collection.mapReduce() method instead. For more information, see db.collection.aggregate(pipeline, options) and db.collection.mapReduce(map,reduce, { <options> }).

  • The $in expression is used with the upsert option set to true to determine whether matching documents exist and the corresponding update operation.

    Example:

    db.c.drop()
    db.c.update({a:{$in:[1]}},{$addToSet:{a:2}},{upsert:true}) //A data record cannot be inserted into a database that runs MongoDB 3.4 but can be inserted into a database that runs a major version earlier than MongoDB 3.4. 
    db.c.update({a:{$elemMatch:{$in:[2] }},{$ addToSet:{a:2 },{ upsert:true}) // A data record can be inserted into a database that runs MongoDB 3.4.

    For more information about the update command, see update.

For more information about MongoDB 3.4, see Compatibility Changes in MongoDB 3.4.

Related API operations

Operation

Description

UpgradeDBInstanceEngineVersion

Upgrades the major version of an ApsaraDB for MongoDB instance.