summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp2
-rw-r--r--src/mongo/db/catalog/database_impl.cpp2
-rw-r--r--src/mongo/db/catalog/index_spec_validate_test.cpp27
-rw-r--r--src/mongo/db/db.cpp2
-rw-r--r--src/mongo/db/keys_collection_cache_reader_and_updater_test.cpp2
-rw-r--r--src/mongo/db/keys_collection_manager_sharding_test.cpp2
-rw-r--r--src/mongo/db/logical_time_validator_test.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp2
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp2
-rw-r--r--src/mongo/db/server_options.h14
-rw-r--r--src/mongo/db/views/view_catalog.cpp2
11 files changed, 16 insertions, 43 deletions
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp
index cc58787cead..977e9144dba 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -172,7 +172,7 @@ StatusWith<CollModRequest> parseCollModRequest(OperationContext* opCtx,
} else if (fieldName == "validator" && !isView) {
MatchExpressionParser::AllowedFeatureSet allowedFeatures =
MatchExpressionParser::kBanAllSpecialFeatures;
- if (!serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load() ||
+ if (!serverGlobalParams.validateFeaturesAsMaster.load() ||
serverGlobalParams.featureCompatibility.isFullyUpgradedTo36()) {
// Note that we don't enforce this restriction on the secondary or on backup
// instances, as indicated by !validateFeaturesAsMaster.
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 1ccf0f50b6b..0706f5a1479 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -1024,7 +1024,7 @@ auto mongo::userCreateNSImpl(OperationContext* opCtx,
// permitted in collection validators.
MatchExpressionParser::AllowedFeatureSet allowedFeatures =
MatchExpressionParser::kBanAllSpecialFeatures;
- if (!serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load() ||
+ if (!serverGlobalParams.validateFeaturesAsMaster.load() ||
serverGlobalParams.featureCompatibility.isFullyUpgradedTo36()) {
// Note that we don't enforce this feature compatibility check when we are on
// the secondary or on a backup instance, as indicated by !validateFeaturesAsMaster.
diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp
index 3b8634c68ef..be5c1135818 100644
--- a/src/mongo/db/catalog/index_spec_validate_test.cpp
+++ b/src/mongo/db/catalog/index_spec_validate_test.cpp
@@ -67,7 +67,6 @@ BSONObj sorted(const BSONObj& obj) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotAnObject) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
@@ -94,7 +93,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotAnObject) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfFieldRepeatedInKeyPattern) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
@@ -115,7 +113,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfFieldRepeatedInKeyPattern) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotPresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::FailedToParse,
validateIndexSpec(kDefaultOpCtx,
@@ -128,7 +125,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotPresent) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotAString) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
@@ -140,7 +136,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotAString) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotPresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::FailedToParse,
validateIndexSpec(kDefaultOpCtx,
@@ -152,7 +147,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotPresent) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsNotAString) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
@@ -175,7 +169,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsNotAString) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsEmptyString) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
@@ -190,7 +183,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsEmptyString) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceDoesNotMatch) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
@@ -216,7 +208,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceDoesNotMatch) {
TEST(IndexSpecValidateTest, ReturnsIndexSpecWithNamespaceFilledInIfItIsNotPresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -244,7 +235,6 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecWithNamespaceFilledInIfItIsNotPresen
TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfNamespaceAndVersionArePresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -270,7 +260,6 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfNamespaceAndVersionArePre
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotANumber) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
@@ -293,7 +282,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotANumber) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
@@ -332,7 +320,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
validateIndexSpec(kDefaultOpCtx,
@@ -347,7 +334,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
validateIndexSpec(kDefaultOpCtx,
@@ -374,7 +360,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) {
TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -416,7 +401,6 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -444,7 +428,6 @@ TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) {
TEST(IndexSpecValidateTest, AcceptsIndexVersionV1) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -468,7 +451,6 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionV1) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
@@ -499,7 +481,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
@@ -514,7 +495,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessThanV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
validateIndexSpec(kDefaultOpCtx,
@@ -532,7 +512,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessTh
TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -584,7 +563,6 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqualToV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -614,7 +592,6 @@ TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqua
TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -631,7 +608,6 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV2) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV1) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -869,7 +845,6 @@ TEST(IndexSpecCollationValidateTest, FillsInCollationFieldWithCollectionDefaultI
TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterIsNotAnObject) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -884,7 +859,6 @@ TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterIsNotAnObject) {
TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterContainsBannedFeature) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
@@ -899,7 +873,6 @@ TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterContainsBannedFeature) {
TEST(IndexSpecPartialFilterTest, AcceptsValidPartialFilterExpression) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
featureCompatibility.setVersion(ServerGlobalParams::FeatureCompatibility::Version::k36);
- featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 8c55f337cc9..b5c3ca89355 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -932,7 +932,7 @@ ExitCode _initAndListen(int listenPort) {
if (replSettings.usingReplSets() || (!replSettings.isMaster() && replSettings.isSlave()) ||
!internalValidateFeaturesAsMaster) {
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.store(false);
+ serverGlobalParams.validateFeaturesAsMaster.store(false);
}
}
diff --git a/src/mongo/db/keys_collection_cache_reader_and_updater_test.cpp b/src/mongo/db/keys_collection_cache_reader_and_updater_test.cpp
index 0010f262705..0dbaacad30a 100644
--- a/src/mongo/db/keys_collection_cache_reader_and_updater_test.cpp
+++ b/src/mongo/db/keys_collection_cache_reader_and_updater_test.cpp
@@ -56,7 +56,7 @@ protected:
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::k36);
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.store(true);
+ serverGlobalParams.validateFeaturesAsMaster.store(true);
auto clockSource = stdx::make_unique<ClockSourceMock>();
operationContext()->getServiceContext()->setFastClockSource(std::move(clockSource));
diff --git a/src/mongo/db/keys_collection_manager_sharding_test.cpp b/src/mongo/db/keys_collection_manager_sharding_test.cpp
index 27e659c38a4..8006238a8c3 100644
--- a/src/mongo/db/keys_collection_manager_sharding_test.cpp
+++ b/src/mongo/db/keys_collection_manager_sharding_test.cpp
@@ -61,7 +61,7 @@ protected:
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::k36);
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.store(true);
+ serverGlobalParams.validateFeaturesAsMaster.store(true);
auto clockSource = stdx::make_unique<ClockSourceMock>();
// Timestamps of "0 seconds" are not allowed, so we must advance our clock mock to the first
diff --git a/src/mongo/db/logical_time_validator_test.cpp b/src/mongo/db/logical_time_validator_test.cpp
index 3f1a9c0bc18..92ddc3213ef 100644
--- a/src/mongo/db/logical_time_validator_test.cpp
+++ b/src/mongo/db/logical_time_validator_test.cpp
@@ -63,7 +63,7 @@ protected:
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::k36);
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.store(true);
+ serverGlobalParams.validateFeaturesAsMaster.store(true);
auto clockSource = stdx::make_unique<ClockSourceMock>();
operationContext()->getServiceContext()->setFastClockSource(std::move(clockSource));
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index 1756870503d..f9c5ce13b78 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -465,7 +465,7 @@ OpTime ReplicationCoordinatorExternalStateImpl::onTransitionToPrimary(OperationC
_shardingOnTransitionToPrimaryHook(opCtx);
_dropAllTempCollections(opCtx);
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.store(true);
+ serverGlobalParams.validateFeaturesAsMaster.store(true);
return opTimeToReturn;
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 6cdc4402bf8..5c0665e7c9a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2534,7 +2534,7 @@ ReplicationCoordinatorImpl::_updateMemberStateFromTopologyCoordinator_inlock(
// _canAcceptNonLocalWrites should already be set above.
invariant(!_canAcceptNonLocalWrites);
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.store(false);
+ serverGlobalParams.validateFeaturesAsMaster.store(false);
result = kActionCloseAllConnections;
} else {
result = kActionFollowerModeStateChange;
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h
index 8e77dc8fd41..1263e272b06 100644
--- a/src/mongo/db/server_options.h
+++ b/src/mongo/db/server_options.h
@@ -224,18 +224,18 @@ struct ServerGlobalParams {
return (isFullyUpgradedTo36() || isUpgradingTo36());
}
- // Feature validation differs depending on the role of a mongod in a replica set or
- // master/slave configuration. Masters/primaries can accept user-initiated writes and
- // validate based on the feature compatibility version. A secondary/slave (which is not also
- // a master) always validates in "3.4" mode so that it can sync 3.4 features, even when in
- // "3.2" feature compatibility mode.
- AtomicWord<bool> validateFeaturesAsMaster{true};
-
private:
AtomicWord<Version> _version{Version::kUnset};
} featureCompatibility;
+ // Feature validation differs depending on the role of a mongod in a replica set or
+ // master/slave configuration. Masters/primaries can accept user-initiated writes and
+ // validate based on the feature compatibility version. A secondary/slave (which is not also
+ // a master) always validates in the upgraded mode so that it can sync new features, even
+ // when in the downgraded feature compatibility mode.
+ AtomicWord<bool> validateFeaturesAsMaster{true};
+
std::vector<std::string> disabledSecureAllocatorDomains;
};
diff --git a/src/mongo/db/views/view_catalog.cpp b/src/mongo/db/views/view_catalog.cpp
index ec654514a1b..7938084d9f5 100644
--- a/src/mongo/db/views/view_catalog.cpp
+++ b/src/mongo/db/views/view_catalog.cpp
@@ -313,7 +313,7 @@ StatusWith<stdx::unordered_set<NamespaceString>> ViewCatalog::_validatePipeline_
"$changeStream cannot be used in a view definition"};
}
- if (serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load() &&
+ if (serverGlobalParams.validateFeaturesAsMaster.load() &&
!serverGlobalParams.featureCompatibility.isFullyUpgradedTo36()) {
auto status = validInViewUnder34FeatureCompatibility(expCtx, *pipelineStatus.getValue());
if (!status.isOK()) {