Compatibility Changes in MongoDB 3.2

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

Default Storage Engine Change

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

For existing deployments, if you do not specify the —storageEngineor the storage.engine setting, MongoDB automaticallydetermines 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 thestorage engine setting either:

  • On the command line with the —storageEngine option:
  1. mongod --storageEngine mmapv1
  1. storage:
  2. engine: mmapv1

Index Changes

Version 0 Indexes

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 logmessage, 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 aforementionedoperations as well as drop and recreate the index to upgrade to thev: 1 version.

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

  • Drop the index either by name:
  1. use test
  2. db.legacyOrders.dropIndex( "x_1" )

or by key:

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

Text Index Version 3 Compatibility

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

2dsphere Index Version 3 Compatibility

2dsphere index (version 3) isincompatible with earlier versions of MongoDB. Earlier versions ofMongoDB will not start if 2dsphere index (version 3) exists in thedatabase.

Aggregation Compatibility Changes

  • $avg accumulator returns null when run against anon-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 aggregationpipeline. Instead, each element of an array is now parsed as anexpression. To treat the element as a literal instead of anexpression, use the $literal operator to create aliteral value.
  • $unwind no longer errors on non-array operands. If the operanddoes 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 anarray, db.collection.aggregate() generated an error.

SpiderMonkey Compatibility Changes

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

See JavaScript Changes in MongoDB 3.2 for more information aboutthis change.

Replica Set Configuration Validation

MongoDB 3.2 provides a stricter validation of replica setconfiguration settings:

Driver Compatibility Changes

A driver upgrade is necessary to support the find andgetMore commands.

General Compatibility Changes

Additional Information

See also Release Notes for MongoDB 3.2.