diff options
Diffstat (limited to 'src/mongo/rpc/object_check.h')
-rw-r--r-- | src/mongo/rpc/object_check.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/rpc/object_check.h b/src/mongo/rpc/object_check.h index c4f999fde20..7c7741ada62 100644 --- a/src/mongo/rpc/object_check.h +++ b/src/mongo/rpc/object_check.h @@ -45,10 +45,19 @@ class Status; template <> struct Validator<BSONObj> { inline static BSONVersion enabledBSONVersion() { - return serverGlobalParams.featureCompatibilityVersion.load() == - ServerGlobalParams::FeatureCompatibilityVersion_34 - ? BSONVersion::kV1_1 - : BSONVersion::kV1_0; + // If we're in the primary/master role accepting writes, but our feature compatibility + // version is 3.2, then we want to reject insertion of the decimal data type. Therefore, we + // perform BSON 1.0 validation. + if (serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load() && + serverGlobalParams.featureCompatibility.version.load() == + ServerGlobalParams::FeatureCompatibility::Version::k32) { + return BSONVersion::kV1_0; + } + + // Except for the special case above, we want to accept any BSON version which we know + // about. For instance, if we are a slave/secondary syncing from a primary/master and we are + // in 3.2 feature compatibility mode, we still want to be able to sync NumberDecimal data. + return BSONVersion::kV1_1; } inline static Status validateLoad(const char* ptr, size_t length) { |