Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

Compatibility Changes in MongoDB 3.2

On this page

  • Default Storage Engine Change
  • Index Changes
  • Aggregation Compatibility Changes
  • SpiderMonkey Compatibility Changes
  • Replica Set Configuration Validation
  • Driver Compatibility Changes
  • General Compatibility Changes
  • Additional Information

The following 3.2 changes can affect the compatibility with older versions of MongoDB. See also Release Notes for MongoDB 3.2 for the list of the 3.2 changes.

Starting in 3.2, MongoDB uses the WiredTiger as the default storage engine. Previous versions used the MMAPv1 as the default storage engine.

For existing deployments, if you do not specify the --storageEngine or the storage.engine setting, MongoDB automatically determines the storage engine used to create the data files in the --dbpath or storage.dbPath.

For new deployments, to use MMAPv1, you must explicitly specify the storage engine setting either:

  • On the command line with the --storageEngine option:

    mongod --storageEngine mmapv1
  • Or in a configuration file, using the storage.engine setting:

    storage:
    engine: mmapv1

MongoDB 3.2 disallows the creation of version 0 indexes (i.e. {v: 0}). If version 0 indexes exist, MongoDB 3.2 outputs a warning log message, specifying the collection and the index.

Starting in MongoDB 2.0, MongoDB started automatically upgrading v: 0 indexes during initial sync, mongorestore or reIndex operations.

If a version 0 index exists, you can use any of the aforementioned operations as well as drop and recreate the index to upgrade to the v: 1 version.

For example, if upon startup, a warning message indicated that an index index { v: 0, key: { x: 1.0 }, name: "x_1", ns: "test.legacyOrders" } is a version 0 index, to upgrade to the appropriate version, you can drop and recreate the index:

  1. Drop the index either by name:

    use test
    db.legacyOrders.dropIndex( "x_1" )

    or by key:

    use test
    db.legacyOrders.dropIndex( { x: 1 } )
  2. Recreate the index without the version option v:

    db.legacyOrders.createIndex( { x: 1 } )

Text index (version 3) is incompatible with earlier versions of MongoDB. Earlier versions of MongoDB will not start if text index (version 3) exists in the database.

2dsphere index (version 3) is incompatible with earlier versions of MongoDB. Earlier versions of MongoDB will not start if 2dsphere index (version 3) exists in the database.

  • $avg accumulator returns null when run against a non-existent field. Previous versions returned 0.

  • $substr errors when the result is an invalid UTF-8. Previous versions output the invalid UTF-8 result.

  • Array elements are no longer treated as literals in the aggregation pipeline. Instead, each element of an array is now parsed as an expression. To treat the element as a literal instead of an expression, use the $literal operator to create a literal value.

  • $unwind no longer errors on non-array operands. If the operand does not resolve to an array but is not missing, null, or an empty array, $unwind treats the operand as a single element array. Previously, if a value in the field specified by the field path was not an array, db.collection.aggregate() generated an error.

MongoDB 3.2 changes the JavaScript engine from V8 to SpiderMonkey. The change allows the use of more modern JavaScript language features, and comes along with minor mongo shell improvements and compatibility changes.

See JavaScript Changes in MongoDB 3.2 for more information about this change.

MongoDB 3.2 provides a stricter validation of replica set configuration settings:

A driver upgrade is necessary to support the find and getMore commands.

See also Release Notes for MongoDB 3.2.

←  3.2 ChangelogJavaScript Changes in MongoDB 3.2 →