On this page
Compatibility Changes in MongoDB 3.4
On this page
The following 3.4 changes can affect the compatibility with older versions of MongoDB.
See also Release Notes for MongoDB 3.4.
Initial Sync and renameCollection
If a collection is renamed on the sync source while an initial sync is running, the initial sync process fails and restarts to avoid possible data corruption. See SERVER-26117 .
Operations that rename collections include:
renameCollectioncommand anddb.collection.renameCollection()method.- Aggregation (
db.collection.aggregate()method oraggregatecommand) with the$outstage. - Map-reduce (
db.collection.mapReduce()method ormapReducecommand) with theoutoption. convertToCappedcommand.
As such, when upgrading from 3.2.11 or earlier versions to 3.4, initial syncs may start failing if they encounter renameCollection operations.
In MongoDB versions 3.2.11 or earlier versions, initial sync process would proceed when encountering renameCollection operations, which could potentially corrupt data. See SERVER-4941 .
Deprecated Operations
group
Mongodb 3.4 deprecates the following commands and mongo shell methods:
groupcommand anddb.collection.group(). Usedb.collection.aggregate()ordb.collection.mapReduce()instead.
aggregate without cursor
MongoDB 3.6 removes the use of aggregate command without the cursor option unless the command includes the explain option. Unless you include the explain option, you must specify the cursor option.
To indicate a cursor with the default batch size, specify cursor: {}.
To indicate a cursor with a non-default batch size, use cursor: { batchSize: <num> }.
Stricter Validation of Collection and Index Specifications
Stricter Validation of Collection Options
MongoDB 3.4 enforces a stricter validation of collection options during create and db.createCollection() operations; namely, the specified options must be valid options supported by create and db.createCollection().
For example, the following operation is no longer valid:
db.createCollection( "myCappedCollection", { cappedtypo: true, size: 5242880 } )
Stricter Validation of Index Specifications
MongoDB 3.4 enforces a stricter validation of index specification during createIndexes and db.collection.createIndex() operations. The enforcement does not apply to existing indexes.
Stricter validation include the following:
Ensuring that the value in the index key pattern
key: valueis valid. Specifically, value can be:Value Description A number greater than 0 For ascending index A number less than 0 For descending index String “text”, “2dsphere”, “2d”, or “hashed” For special index types For example, the following operations are no longer valid:
db.collection.createIndex( { x: 0 } ); db.collection.createIndex( { y: "text2d" } ); db.collection.createIndex( { z: NaN } ); db.collection.createIndex( { x: 1, unique: true } )Ensuring that the specified index options are valid. Previous versions ignored invalid options. For example, the following operations are no longer valid:
db.collection.createIndex( { y: 1 }, { uniques2: true} ); db.collection.createIndex( { z: 1 }, { expireAfterSec: 350 } )
General Compatibility Changes
Updates to namespace restrictions: in MongodDB 3.4, the
$character is no longer supported in database names.Important
You must drop any databases that contain a
$in its name before upgrading to MongoDB 3.4.Removal of deprecated
textSearchEnabledparameter. Starting from version 2.6, MongoDB enables the text search feature by default.Removal of
mongosniff. In MongoDB 3.4,mongosniffis replaced bymongoreplay, which offers a more flexible superset ofmongosniff’s functionality.Updates to
$projectspecification behavior: empty documents in$projectspecifications produce an error.If you include a
hint()that specifies a sparse index when you perform a