Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

setFeatureCompatibilityVersion

On this page

  • Definition
  • Syntax
  • Behavior
  • Examples
setFeatureCompatibilityVersion

Enables or disables the features that persist data incompatible with earlier versions of MongoDB. You can only issue the setFeatureCompatibilityVersion against the admin database.

The command takes the following form:

db.adminCommand( {
setFeatureCompatibilityVersion: <version>,
writeConcern: { wtimeout: <timeout> }
} )

The values for the version are:

Version
Description
"4.4"

Available on MongoDB 4.4 Deployments

Enables the 4.4 features that persist data incompatible with MongoDB 4.2.

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.

"4.2"

Available on MongoDB 4.2 and 4.4 Deployments

Enables the 4.2 features that persist data incompatible with MongoDB 4.0.

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.

"4.0"

Available on MongoDB 4.0 and 4.2 Deployments

  • If set on MongoDB 4.0 deployments,

    Enables the 4.0 features that persist data incompatible with MongoDB 3.6.

    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.

  • If set on MongoDB 4.2 deployments,
    Disables the 4.2 features that persist data incompatible with MongoDB 4.0.
"3.6"

Available on MongoDB 3.6 and 4.0 Deployments

  • If set 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.

  • If set on MongoDB 4.0 deployments,
    Disables the 4.0 features that persist data incompatible with MongoDB 3.6.
"3.4"

Available on MongoDB 3.4 and MongoDB 3.6 Deployments

"3.2"

Available on MongoDB 3.4 Deployments

Disables the 3.4 features that persist data incompatible with MongoDB 3.2.

The optional writeConcern specifies the write concern wtimeout value in milliseconds:

  • The time period that the primary waits for acknowledgment from the majority of the replica set members. If the acknowledgment is not received in the time period, the operation fails.

  • Default is 60000 milliseconds. Use a longer time period if the secondary members of the replica set have a delay that exceeds the wtimeout default.

Note

  • For a standalone, run the command on the standalone mongod instance.

  • 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 mongos instance.

Certain background operations may prevent execution of setFeatureCompatibilityVersion. Use currentOp to identify any ongoing operations.

If you trigger a setFeatureCompatibilityVersion change during an initial sync, the sync may fail with an OplogOperationUnsupported error message when replaying entries on the oplog application phase. The sync following this attempt succeeds because the operation phase no longer replays the operation.

Deployments
featureCompatibilityVersion
For new 4.4 deployments
"4.4"
For 4.4 deployments upgraded from 4.2
"4.2" until you setFeatureCompatibilityVersion to "4.4".
For new 4.2 deployments
"4.2"
For 4.2 deployments upgraded from 4.0
"4.0" until you setFeatureCompatibilityVersion to "4.2".
For new 4.0 deployments
"4.0"
For 4.0 deployments upgraded from 3.6
"3.6" until you setFeatureCompatibilityVersion to "4.0".
For new 3.6 deployments
"3.6"
For 3.6 deployments upgraded from 3.4
"3.4" until you setFeatureCompatibilityVersion to "3.6".
For new 3.4 deployments
"3.4"
For 3.4 deployments upgraded from 3.2
"3.2" until you setFeatureCompatibilityVersion to "3.4".

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.

Arbiters do not replicate the admin.system.version collection. Because of this, arbiters always have a feature compatibility version equal to the downgrade version of the binary, regardless of the fCV value of the replica set.

For example, an arbiter in a MongoDB 4.4 cluster, has an fCV value of 4.2.

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 format of the featureCompatibilityVersion depends on the MongoDB version. Click on the tab for the appropriate MongoDB version.

The following example sets the optional write concern wtimeout field to 5000 (5 seconds).

Note

Run the setFeatureCompatibilityVersion command against the admin database.

  • For a standalone, run the command on the standalone mongod instance.

  • 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 mongos instance.

db.adminCommand( {
setFeatureCompatibilityVersion: "4.4",
writeConcern: { wtimeout: 5000 }
} )
← renameCollection