Compatibility Changes in MongoDB 3.2
On this page
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.
Default Storage Engine Change
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
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 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:
Drop the index either by name:
use test db.legacyOrders.dropIndex( "x_1" ) or by key:
use test db.legacyOrders.dropIndex( { x: 1 } ) Recreate the index without the version option
v
:db.legacyOrders.createIndex( { x: 1 } )
Text Index Version 3 Compatibility
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 Compatibility
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.
Aggregation Compatibility Changes
$avg
accumulator returns null when run against a non-existent field. Previous versions returned0
.$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.
SpiderMonkey Compatibility Changes
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.
Replica Set Configuration Validation
MongoDB 3.2 provides a stricter validation of replica set configuration settings:
Driver Compatibility Changes
A driver upgrade is necessary to support the find
and
getMore
commands.
General Compatibility Changes
In MongoDB 3.2,
cursor.showDiskLoc()
is deprecated in favor ofcursor.showRecordId()
, and both return a new document format.MongoDB 3.2 renamed the
serverStatus.repl.slaves
field torepl.replicationProgress
. See: the db.serverStatus() repl reference for more information.The default changed from
--moveParanoia
to--noMoveParanoia
.Replica set members with
1 vote
cannot sync from members with0 votes
.mongooplog
is deprecated starting in MongoDB 3.2.
Additional Information
See also Release Notes for MongoDB 3.2.