On this page
setFeatureCompatibilityVersion
On this page
Definition
setFeatureCompatibilityVersion- 
     
New in version 3.4.
Changed in version 3.6.
Enables or disables the features that persist data incompatible with earlier versions of MongoDB. You can only issue the
setFeatureCompatibilityVersionagainst theadmindatabase.The command takes the following form:
db.adminCommand( { setFeatureCompatibilityVersion: <version> } )The values for the
versionare:Version Description "3.6"Available on MongoDB 3.6 Deployments
Enables the 3.6 features that persist data incompatible with MongoDB 3.4.
Enabling these backwards-incompatible features can complicate the downgrade process since you must remove any persisted backwards-incompatible features before you downgrade.
It is recommended that after upgrading, you allow your deployment to run without enabling these features for a burn-in period to ensure the likelihood of downgrade is minimal. When you are confident that the likelihood of downgrade is minimal, enable these features.
"3.4"Available on MongoDB 3.4 and MongoDB 3.6 Deployments
- 
            
- If set on MongoDB 3.4 deployments,
 - 
              
Enables the 3.4 features that persist data incompatible with MongoDB 3.2.
 
Enabling these backwards-incompatible features can complicate the downgrade process. For details, see Remove 3.4 Incompatible Features.
It is recommended that after upgrading, you allow your deployment to run without enabling these features for a burn-in period to ensure the likelihood of downgrade is minimal. When you are confident that the likelihood of downgrade is minimal, enable these features.
 - 
            
- If set on MongoDB 3.6 deployments,
 - 
              
Disables the 3.6 features that persist data incompatible with MongoDB 3.4.
 
 
"3.2"Available on MongoDB 3.4 Deployments
Disables the 3.4 features that persist data incompatible with MongoDB 3.2.
 - 
            
 
Behavior
Conflicts with Background Operations
Certain background operations, such as index builds, may prevent execution of setFeatureCompatibilityVersion. Use currentOp to identify any ongoing operations.
Default Values
| Deployments | featureCompatibilityVersion | 
       
|---|---|
| For new 3.6 deployments | "3.6" | 
       
| For deployments upgraded from 3.4 | "3.4" until you setFeatureCompatibilityVersion to "3.6". | 
       
| For new 3.4 deployments | "3.4" | 
       
| For deployments upgraded from 3.2 | "3.2" until you setFeatureCompatibilityVersion to "3.4". | 
       
Idempotency
This command must perform writes to an internal system collection. If for any reason the command does not complete successfully, you can safely retry the command as the operation is idempotent.
Access Control
To run setFeatureCompatibilityVersion if your deployment enforces access control, you must have a role that grants the following privilege:
{
  resource: { db: "$setFeatureCompatibilityVersion", collection: "version" },
  actions: [ "update" ]
}
      The clusterAdmin and clusterManager roles grant privileges to run setFeatureCompatibilityVersion. [1]
The clusterAdmin also grants privileges to view featureCompatibilityVersion.
Alternatively, you can create a custom role with just the privileges to run setFeatureCompatibilityVersion and getParameter to view featureCompatibilityVersion:
db.getSiblingDB("admin").createRole({
   role: "fcvRole",
   privileges: [
      { resource: { db: "$setFeatureCompatibilityVersion", collection: "version" }, actions: [ "update" ] },
      { resource: { cluster: true }, actions: [ "getParameter" ] }
   ],
   roles: [ ]
})
      See also
| [1] | For MongoDB 3.6.0-3.6.7, readWriteAnyDatabase role also grants privileges to run setFeatureCompatibilityVersion. | 
       
Examples
View FeatureCompatibilityVersion
To view the featureCompatibilityVersion for a mongod instance, run the following command on a mongod instance:
Note
The operation is undefined on the mongos instances. For a sharded cluster that has access control enabled, to run the command against a member of the shard replica set, you must connect to the member as a shard local user.
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
      In the results document, the value of the featureCompatibilityVersion can have one of the following forms.
For MongoDB 3.4 mongod instances:
"featureCompatibilityVersion" : <version>
      For MongoDB 3.6+ mongod instances:
If the deployment has the default
featureCompatibilityVersion, or if thesetFeatureCompatibilityVersioncommand has run successfully against the deployment, thefeatureCompatibilityVersionhas the form:"featureCompatibilityVersion" : { "version" : <version> }If the
mongodis in a partially upgraded or downgraded state, thefeatureCompatibilityVersionhas the following form:"featureCompatibilityVersion" : { "version" : <version> , "targetVersion" : <target version> }For instance, if a sharded cluster has a shard replica set that is read only when you run
setFeatureCompatibilityVersioncommand against themongos, the command will fail, and thefeatureCompatibilityVersionof the config servers will include thetargetVersionfield.Or if a replica set becomes read only while
setFeatureCompatibilityVersionis running, the command will fail, and thefeatureCompatibilityVersionof the replica set will include thetargetVersionfield as well.
Set Feature Compatibility Version on MongoDB 3.6 Deployments
Enable 3.6 Backwards Incompatible Features
To enable the 3.6 features that persist data incompatible with MongoDB 3.4, set the feature compatibility to "3.6" on the MongoDB 3.6 deployment:
Note
Run the setFeatureCompatibilityVersion command against the admin database.
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
       Disable 3.6 Backwards Incompatible Features
To disable the 3.6 features that persist data incompatible with MongoDB 3.4, set the feature compatibility to "3.4" on the MongoDB 3.6 deployment:
Note
Run the setFeatureCompatibilityVersion command against the admin database.
- For a standalone, run the command on the standalone 
mongodinstance. - For a replica set, run the command on the primary. A majority of the data-bearing members must be available.
 - For a sharded cluster, run the command on a 
mongosinstance. "3.4"featureCompatibilityVersion is supported on MongoDB 3.6 and MongoDB 3.4 Deployments Only.
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
       If run as part of the downgrade process from MongoDB 3.6 to MongoDB 3.4, you must also remove all persisted features that are incompatible with 3.4. See the appropriate downgrade procedures.
Set Feature Compatibility Version on MongoDB 3.4 Deployments
Enable 3.4 Backwards Incompatible Features
Warning
Enabling these backwards-incompatible features can complicate the downgrade process. For details, see Remove 3.4 Incompatible Features.
It is recommended that after upgrading, you allow your deployment to run without enabling these features for a burn-in period to ensure the likelihood of downgrade is minimal. When you are confident that the likelihood of downgrade is minimal, enable these features.
To