summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2017-06-02 15:29:32 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2017-06-09 15:05:04 -0400
commit67500efdc1c677173c737ecde2b07b42015ae5fd (patch)
tree4a735cf4c6561e28b76f65117d47231e9a677d04 /src/mongo
parentf9c36696a25d3837f512421755952736236bbed0 (diff)
downloadmongo-67500efdc1c677173c737ecde2b07b42015ae5fd.tar.gz
SERVER-29350 Bump featureCompatibilityVersion to 3.6
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/bson/bson_validate.cpp15
-rw-r--r--src/mongo/db/catalog/SConscript1
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp12
-rw-r--r--src/mongo/db/catalog/index_spec_validate_test.cpp142
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/count_cmd.cpp19
-rw-r--r--src/mongo/db/commands/dbcommands.cpp13
-rw-r--r--src/mongo/db/commands/distinct.cpp19
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.cpp199
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.h21
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_command_parser.cpp24
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_command_parser.h3
-rw-r--r--src/mongo/db/commands/find_cmd.cpp19
-rw-r--r--src/mongo/db/commands/geo_near_cmd.cpp10
-rw-r--r--src/mongo/db/commands/group_cmd.cpp8
-rw-r--r--src/mongo/db/commands/list_indexes.cpp21
-rw-r--r--src/mongo/db/commands/mr.cpp24
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp34
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp10
-rw-r--r--src/mongo/db/index/index_descriptor.cpp32
-rw-r--r--src/mongo/db/ops/parsed_delete.cpp9
-rw-r--r--src/mongo/db/ops/parsed_update.cpp8
-rw-r--r--src/mongo/db/repl/replication_info.cpp84
-rw-r--r--src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp4
-rw-r--r--src/mongo/db/server_options.h15
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp3
-rw-r--r--src/mongo/db/views/view_catalog.cpp17
-rw-r--r--src/mongo/db/views/view_catalog_test.cpp8
-rw-r--r--src/mongo/dbtests/dbtests.cpp7
-rw-r--r--src/mongo/dbtests/jstests.cpp20
-rw-r--r--src/mongo/rpc/object_check.h17
-rw-r--r--src/mongo/rpc/protocol.cpp6
-rw-r--r--src/mongo/rpc/protocol.h5
-rw-r--r--src/mongo/s/catalog/sharding_catalog_add_shard_test.cpp28
-rw-r--r--src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp32
-rw-r--r--src/mongo/s/catalog/sharding_catalog_manager_shard_operations_impl.cpp34
-rw-r--r--src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp10
-rw-r--r--src/mongo/s/server.cpp8
-rw-r--r--src/mongo/shell/dbshell.cpp8
-rw-r--r--src/mongo/shell/shardingtest.js16
-rw-r--r--src/mongo/shell/utils.js2
-rw-r--r--src/mongo/transport/session.h3
42 files changed, 298 insertions, 673 deletions
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp
index c2d97a6496e..efde629c8e2 100644
--- a/src/mongo/bson/bson_validate.cpp
+++ b/src/mongo/bson/bson_validate.cpp
@@ -253,18 +253,9 @@ Status validateElementInfo(Buffer* buffer,
return Status::OK();
case NumberDecimal:
- if (buffer->version() != BSONVersion::kV1_0) {
- if (!buffer->skip(sizeof(Decimal128::Value)))
- return makeError("Invalid bson", idElem, *elemName);
- return Status::OK();
- } else {
- return makeError(
- "Cannot use decimal BSON type when the featureCompatibilityVersion "
- "is 3.2. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility. Found decimal",
- idElem,
- *elemName);
- }
+ if (!buffer->skip(sizeof(Decimal128::Value)))
+ return makeError("Invalid bson", idElem, *elemName);
+ return Status::OK();
case DBRef:
status = buffer->readUTF8String(*elemName, nullptr);
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index 20180689ef7..ab20e3dd984 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -178,7 +178,6 @@ env.Library(
'$BUILD_DIR/mongo/db/query/query',
'$BUILD_DIR/mongo/db/repl/drop_pending_collection_reaper',
'$BUILD_DIR/mongo/db/repl/serveronly',
- '$BUILD_DIR/mongo/db/server_options_core',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/storage/mmap_v1/storage_mmapv1',
'$BUILD_DIR/mongo/db/storage/key_string',
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index e6a0c2b64b6..04fdfc57442 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -1005,16 +1005,8 @@ public:
virtual Status validate(const RecordId& recordId, const RecordData& record, size_t* dataSize) {
BSONObj recordBson = record.toBson();
- // Secondaries are configured to always validate using the latest enabled BSON version. But
- // users should be able to run collection validation on a secondary in "3.2"
- // featureCompatibilityVersion in order to be alerted to the presence of NumberDecimal.
- auto bsonValidationVersion = (serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32)
- ? BSONVersion::kV1_0
- : Validator<BSONObj>::enabledBSONVersion();
-
- const Status status =
- validateBSON(recordBson.objdata(), recordBson.objsize(), bsonValidationVersion);
+ const Status status = validateBSON(
+ recordBson.objdata(), recordBson.objsize(), Validator<BSONObj>::enabledBSONVersion());
if (status.isOK()) {
*dataSize = recordBson.objsize();
} else {
diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp
index 45e65b00d6f..bb4cc4c1c1f 100644
--- a/src/mongo/db/catalog/index_spec_validate_test.cpp
+++ b/src/mongo/db/catalog/index_spec_validate_test.cpp
@@ -65,7 +65,7 @@ BSONObj sorted(const BSONObj& obj) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotAnObject) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
@@ -89,7 +89,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotAnObject) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfFieldRepeatedInKeyPattern) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
@@ -108,7 +108,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfFieldRepeatedInKeyPattern) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotPresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::FailedToParse,
@@ -120,7 +120,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotPresent) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotAString) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
@@ -131,7 +131,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotAString) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotPresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(
@@ -141,7 +141,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotPresent) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsNotAString) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
@@ -162,7 +162,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsNotAString) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsEmptyString) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
@@ -176,7 +176,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsEmptyString) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceDoesNotMatch) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
@@ -200,7 +200,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceDoesNotMatch) {
TEST(IndexSpecValidateTest, ReturnsIndexSpecWithNamespaceFilledInIfItIsNotPresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -226,7 +226,7 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecWithNamespaceFilledInIfItIsNotPresen
TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfNamespaceAndVersionArePresent) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -251,7 +251,7 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfNamespaceAndVersionArePre
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotANumber) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
@@ -272,7 +272,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotANumber) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
@@ -307,7 +307,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
@@ -321,7 +321,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
@@ -344,46 +344,9 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) {
featureCompatibility));
}
-TEST(IndexSpecValidateTest, ReturnsAnErrorIfIndexVersionIsV2AndFeatureCompatibilityVersionIs32) {
- ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k32);
- featureCompatibility.validateFeaturesAsMaster.store(true);
-
- ASSERT_EQ(ErrorCodes::CannotCreateIndex,
- validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "v"
- << 2),
- kTestNamespace,
- featureCompatibility));
-}
-
-TEST(IndexSpecValidateTest, AcceptsIndexVersionV2WhenValidateFeaturesAsMasterFalse) {
- ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k32);
- featureCompatibility.validateFeaturesAsMaster.store(false);
-
- auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "v"
- << 2),
- kTestNamespace,
- featureCompatibility);
- ASSERT_OK(result.getStatus());
-
- // We don't care about the order of the fields in the resulting index specification.
- ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "ns"
- << kTestNamespace.ns()
- << "v"
- << 2)),
- sorted(result.getValue()));
-}
-
TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -421,62 +384,9 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
sorted(result.getValue()));
}
-TEST(IndexSpecValidateTest, DefaultIndexVersionIsV1IfFeatureCompatibilityVersionIs32) {
- ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k32);
- featureCompatibility.validateFeaturesAsMaster.store(true);
-
- auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "ns"
- << kTestNamespace.ns()),
- kTestNamespace,
- featureCompatibility);
- ASSERT_OK(result.getStatus());
-
- // We don't care about the order of the fields in the resulting index specification.
- ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "ns"
- << kTestNamespace.ns()
- << "v"
- << 1)),
- sorted(result.getValue()));
-
- // Verify that the index specification we returned is still considered valid.
- ASSERT_OK(validateIndexSpec(result.getValue(), kTestNamespace, featureCompatibility));
-}
-
-TEST(IndexSpecValidateTest,
- DefaultIndexVersionIsV1IfFeatureCompatibilityVersionIs32AndValidateFeaturesAsMasterFalse) {
- ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k32);
- featureCompatibility.validateFeaturesAsMaster.store(false);
-
- auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "ns"
- << kTestNamespace.ns()),
- kTestNamespace,
- featureCompatibility);
- ASSERT_OK(result.getStatus());
-
- // We don't care about the order of the fields in the resulting index specification.
- ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name"
- << "indexName"
- << "ns"
- << kTestNamespace.ns()
- << "v"
- << 1)),
- sorted(result.getValue()));
-
- // Verify that the index specification we returned is still considered valid.
- ASSERT_OK(validateIndexSpec(result.getValue(), kTestNamespace, featureCompatibility));
-}
-
-TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2IfFeatureCompatibilityVersionIs34) {
+TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -500,9 +410,9 @@ TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2IfFeatureCompatibilityVersion
ASSERT_OK(validateIndexSpec(result.getValue(), kTestNamespace, featureCompatibility));
}
-TEST(IndexSpecValidateTest, AcceptsIndexVersionV1WhenFeatureCompatibilityVersionIs34) {
+TEST(IndexSpecValidateTest, AcceptsIndexVersionV1) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -525,7 +435,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionV1WhenFeatureCompatibilityVersion
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::TypeMismatch,
@@ -553,7 +463,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::BadValue,
@@ -567,7 +477,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessThanV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
@@ -584,7 +494,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessTh
TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -634,7 +544,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqualToV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -663,7 +573,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqua
TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV2) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
@@ -679,7 +589,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV2) {
TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV1) {
ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k34);
+ featureCompatibility.version.store(ServerGlobalParams::FeatureCompatibility::Version::k36);
featureCompatibility.validateFeaturesAsMaster.store(true);
auto result = validateIndexSpec(BSON("key" << BSON("field" << 1) << "name"
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index a48936a12d6..ddd8fbcfb5d 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -115,7 +115,6 @@ env.Library(
'core',
'$BUILD_DIR/mongo/db/commands',
'$BUILD_DIR/mongo/db/db_raii',
- '$BUILD_DIR/mongo/db/index_d',
],
)
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index bb836ace5dd..b34eb049b0b 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/query/plan_summary_stats.h"
#include "mongo/db/query/view_response_formatter.h"
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/views/resolved_view.h"
#include "mongo/util/log.h"
@@ -111,14 +110,6 @@ public:
return request.getStatus();
}
- if (!request.getValue().getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
// Acquire the db read lock.
AutoGetCollectionOrViewForReadCommand ctx(opCtx, request.getValue().getNs());
Collection* collection = ctx.getCollection();
@@ -175,16 +166,6 @@ public:
return appendCommandStatus(result, request.getStatus());
}
- if (!request.getValue().getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return appendCommandStatus(
- result,
- Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."));
- }
-
AutoGetCollectionOrViewForReadCommand ctx(opCtx, request.getValue().getNs());
Collection* collection = ctx.getCollection();
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index f2760314ed7..bb59ebe0ba3 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -545,19 +545,6 @@ public:
result.append("note", deprecationWarning);
}
- auto featureCompatibilityVersion = serverGlobalParams.featureCompatibility.version.load();
- auto validateFeaturesAsMaster =
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load();
- if (ServerGlobalParams::FeatureCompatibility::Version::k32 == featureCompatibilityVersion &&
- validateFeaturesAsMaster && cmdObj.hasField("collation")) {
- return appendCommandStatus(
- result,
- {ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to create a collection or "
- "view with a default collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."});
- }
-
// Validate _id index spec and fill in missing fields.
if (auto idIndexElem = cmdObj["idIndex"]) {
if (cmdObj["viewOn"]) {
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 6643c952395..521862f0ccf 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -59,7 +59,6 @@
#include "mongo/db/query/plan_summary_stats.h"
#include "mongo/db/query/query_planner_common.h"
#include "mongo/db/query/view_response_formatter.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/views/resolved_view.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/log.h"
@@ -125,14 +124,6 @@ public:
return parsedDistinct.getStatus();
}
- if (!parsedDistinct.getValue().getQuery()->getQueryRequest().getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
AutoGetCollectionOrViewForReadCommand ctx(opCtx, nss);
Collection* collection = ctx.getCollection();
@@ -177,16 +168,6 @@ public:
return appendCommandStatus(result, parsedDistinct.getStatus());
}
- if (!parsedDistinct.getValue().getQuery()->getQueryRequest().getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return appendCommandStatus(
- result,
- Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."));
- }
-
AutoGetCollectionOrViewForReadCommand ctx(opCtx, nss);
Collection* collection = ctx.getCollection();
diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp
index 4fd5a6573e6..9184c309049 100644
--- a/src/mongo/db/commands/feature_compatibility_version.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version.cpp
@@ -33,28 +33,21 @@
#include "mongo/db/commands/feature_compatibility_version.h"
#include "mongo/base/status.h"
-#include "mongo/db/catalog/collection_options.h"
-#include "mongo/db/commands/feature_compatibility_version_command_parser.h"
-#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
-#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/index_builder.h"
#include "mongo/db/operation_context.h"
-#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/transport/transport_layer.h"
#include "mongo/util/log.h"
namespace mongo {
using repl::UnreplicatedWritesBlock;
-constexpr StringData FeatureCompatibilityVersion::k32IncompatibleIndexName;
constexpr StringData FeatureCompatibilityVersion::kCollection;
constexpr StringData FeatureCompatibilityVersion::kCommandName;
constexpr StringData FeatureCompatibilityVersion::kDatabase;
@@ -62,16 +55,6 @@ constexpr StringData FeatureCompatibilityVersion::kParameterName;
constexpr StringData FeatureCompatibilityVersion::kVersionField;
namespace {
-const BSONObj k32IncompatibleIndexSpec =
- BSON(IndexDescriptor::kIndexVersionFieldName
- << static_cast<int>(IndexDescriptor::IndexVersion::kV2)
- << IndexDescriptor::kKeyPatternFieldName
- << BSON(FeatureCompatibilityVersion::kVersionField << 1)
- << IndexDescriptor::kNamespaceFieldName
- << FeatureCompatibilityVersion::kCollection
- << IndexDescriptor::kIndexNameFieldName
- << FeatureCompatibilityVersion::k32IncompatibleIndexName);
-
BSONObj makeUpdateCommand(StringData newVersion, BSONObj writeConcern) {
BSONObjBuilder updateCmd;
@@ -99,18 +82,6 @@ BSONObj makeUpdateCommand(StringData newVersion, BSONObj writeConcern) {
return updateCmd.obj();
}
-
-StringData getFeatureCompatibilityVersionString(
- ServerGlobalParams::FeatureCompatibility::Version version) {
- switch (version) {
- case ServerGlobalParams::FeatureCompatibility::Version::k34:
- return FeatureCompatibilityVersionCommandParser::kVersion34;
- case ServerGlobalParams::FeatureCompatibility::Version::k32:
- return FeatureCompatibilityVersionCommandParser::kVersion32;
- default:
- MONGO_UNREACHABLE;
- }
-}
} // namespace
StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibilityVersion::parse(
@@ -137,12 +108,12 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
<< FeatureCompatibilityVersion::kCollection
<< ": "
<< featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
- if (elem.String() == FeatureCompatibilityVersionCommandParser::kVersion34) {
+ if (elem.String() == FeatureCompatibilityVersionCommandParser::kVersion36) {
+ version = ServerGlobalParams::FeatureCompatibility::Version::k36;
+ } else if (elem.String() == FeatureCompatibilityVersionCommandParser::kVersion34) {
version = ServerGlobalParams::FeatureCompatibility::Version::k34;
- } else if (elem.String() == FeatureCompatibilityVersionCommandParser::kVersion32) {
- version = ServerGlobalParams::FeatureCompatibility::Version::k32;
} else {
return Status(
ErrorCodes::BadValue,
@@ -152,16 +123,16 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
<< ", found "
<< elem.String()
<< ", expected '"
- << FeatureCompatibilityVersionCommandParser::kVersion34
+ << FeatureCompatibilityVersionCommandParser::kVersion36
<< "' or '"
- << FeatureCompatibilityVersionCommandParser::kVersion32
+ << FeatureCompatibilityVersionCommandParser::kVersion34
<< "'. Contents of "
<< FeatureCompatibilityVersion::kParameterName
<< " document in "
<< FeatureCompatibilityVersion::kCollection
<< ": "
<< featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
} else {
return Status(
@@ -172,7 +143,7 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
<< FeatureCompatibilityVersion::kCollection
<< ": "
<< featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
}
@@ -187,7 +158,7 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
<< FeatureCompatibilityVersion::kCollection
<< ": "
<< featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
return version;
@@ -195,96 +166,35 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
void FeatureCompatibilityVersion::set(OperationContext* opCtx, StringData version) {
uassert(40284,
- "featureCompatibilityVersion must be '3.4' or '3.2'. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.",
- version == FeatureCompatibilityVersionCommandParser::kVersion34 ||
- version == FeatureCompatibilityVersionCommandParser::kVersion32);
+ "featureCompatibilityVersion must be '3.6' or '3.4'. See "
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.",
+ version == FeatureCompatibilityVersionCommandParser::kVersion36 ||
+ version == FeatureCompatibilityVersionCommandParser::kVersion34);
DBDirectClient client(opCtx);
NamespaceString nss(FeatureCompatibilityVersion::kCollection);
- if (version == FeatureCompatibilityVersionCommandParser::kVersion34) {
- // We build a v=2 index on the "admin.system.version" collection as part of setting the
- // featureCompatibilityVersion to 3.4. This is a new index version that isn't supported by
- // versions of MongoDB earlier than 3.4 that will cause 3.2 secondaries to crash when it is
- // replicated.
- std::vector<BSONObj> indexSpecs{k32IncompatibleIndexSpec};
-
- {
- AutoGetOrCreateDb autoDB(opCtx, nss.db(), MODE_X);
-
- uassert(ErrorCodes::NotMaster,
- str::stream() << "Cannot set featureCompatibilityVersion to '" << version
- << "'. Not primary while attempting to create index on: "
- << nss.ns(),
- repl::ReplicationCoordinator::get(opCtx->getServiceContext())
- ->canAcceptWritesFor(opCtx, nss));
-
- // If the "admin.system.version" collection has not been created yet, explicitly create
- // it to hold the v=2 index.
- if (!autoDB.getDb()->getCollection(opCtx, nss)) {
- uassertStatusOK(
- repl::StorageInterface::get(opCtx)->createCollection(opCtx, nss, {}));
- }
-
- IndexBuilder builder(k32IncompatibleIndexSpec, false);
- auto status = builder.buildInForeground(opCtx, autoDB.getDb());
- uassertStatusOK(status);
-
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- WriteUnitOfWork wuow(opCtx);
- auto uuid = autoDB.getDb()->getCollection(opCtx, nss)->uuid();
- getGlobalServiceContext()->getOpObserver()->onCreateIndex(
- opCtx, nss, uuid, k32IncompatibleIndexSpec, false);
- wuow.commit();
- }
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(
- opCtx, "FeatureCompatibilityVersion::set", nss.ns());
- }
-
- // We then update the featureCompatibilityVersion document stored in the
- // "admin.system.version" collection. We do this after creating the v=2 index in order to
- // maintain the invariant that if the featureCompatibilityVersion is 3.4, then
- // 'k32IncompatibleIndexSpec' index exists on the "admin.system.version" collection.
- BSONObj updateResult;
- client.runCommand(nss.db().toString(),
- makeUpdateCommand(version, WriteConcernOptions::Majority),
- updateResult);
- uassertStatusOK(getStatusFromCommandResult(updateResult));
- uassertStatusOK(getWriteConcernStatusFromCommandResult(updateResult));
-
- // We then update the value of the featureCompatibilityVersion server parameter.
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
- } else if (version == FeatureCompatibilityVersionCommandParser::kVersion32) {
- // We update the featureCompatibilityVersion document stored in the "admin.system.version"
- // collection. We do this before dropping the v=2 index in order to maintain the invariant
- // that if the featureCompatibilityVersion is 3.4, then 'k32IncompatibleIndexSpec' index
- // exists on the "admin.system.version" collection. We don't attach a "majority" write
- // concern to this update because we're going to do so anyway for the "dropIndexes" command.
- BSONObj updateResult;
- client.runCommand(nss.db().toString(), makeUpdateCommand(version, BSONObj()), updateResult);
- uassertStatusOK(getStatusFromCommandResult(updateResult));
-
- // We then drop the v=2 index on the "admin.system.version" collection to enable 3.2
- // secondaries to sync from this mongod.
- BSONObjBuilder dropIndexesCmd;
- dropIndexesCmd.append("dropIndexes", nss.coll());
- dropIndexesCmd.append("index", FeatureCompatibilityVersion::k32IncompatibleIndexName);
- dropIndexesCmd.append("writeConcern", WriteConcernOptions::Majority);
-
- BSONObj dropIndexesResult;
- client.runCommand(nss.db().toString(), dropIndexesCmd.done(), dropIndexesResult);
- auto status = getStatusFromCommandResult(dropIndexesResult);
- if (status != ErrorCodes::IndexNotFound) {
- uassertStatusOK(status);
- }
- uassertStatusOK(getWriteConcernStatusFromCommandResult(dropIndexesResult));
-
- // We then update the value of the featureCompatibilityVersion server parameter.
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k32);
+ // Update the featureCompatibilityVersion document stored in the "admin.system.version"
+ // collection.
+ BSONObj updateResult;
+ client.runCommand(nss.db().toString(),
+ makeUpdateCommand(version, WriteConcernOptions::Majority),
+ updateResult);
+ uassertStatusOK(getStatusFromCommandResult(updateResult));
+ uassertStatusOK(getWriteConcernStatusFromCommandResult(updateResult));
+
+ // Close all internal connections to versions lower than 3.6.
+ if (version == FeatureCompatibilityVersionCommandParser::kVersion36) {
+ opCtx->getServiceContext()->getTransportLayer()->endAllSessions(
+ transport::Session::kLatestVersionInternalClientKeepOpen |
+ transport::Session::kExternalClientKeepOpen);
}
+
+ // Update the value of the featureCompatibilityVersion server parameter.
+ serverGlobalParams.featureCompatibility.version.store(
+ version == FeatureCompatibilityVersionCommandParser::kVersion36
+ ? ServerGlobalParams::FeatureCompatibility::Version::k36
+ : ServerGlobalParams::FeatureCompatibility::Version::k34);
}
void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx,
@@ -303,42 +213,28 @@ void FeatureCompatibilityVersion::setIfCleanStartup(OperationContext* opCtx,
UnreplicatedWritesBlock unreplicatedWritesBlock(opCtx);
NamespaceString nss(FeatureCompatibilityVersion::kCollection);
- // We build a v=2 index on the "admin.system.version" collection as part of setting the
- // featureCompatibilityVersion to 3.4. This is a new index version that isn't supported by
- // versions of MongoDB earlier than 3.4 that will cause 3.2 secondaries to crash when it is
- // cloned.
- std::vector<BSONObj> indexSpecs{k32IncompatibleIndexSpec};
-
{
AutoGetOrCreateDb autoDB(opCtx, nss.db(), MODE_X);
// We reached this point because the only database that exists on the server is "local"
- // and we have just created an empty "admin" database.
- // Therefore, it is safe to create the "admin.system.version" collection.
+ // and we have just created an empty "admin" database. Therefore, it is safe to create
+ // the "admin.system.version" collection.
invariant(autoDB.justCreated());
uassertStatusOK(storageInterface->createCollection(opCtx, nss, {}));
-
- IndexBuilder builder(k32IncompatibleIndexSpec, false);
- auto status = builder.buildInForeground(opCtx, autoDB.getDb());
- uassertStatusOK(status);
}
// We then insert the featureCompatibilityVersion document into the "admin.system.version"
- // collection. We do this after creating the v=2 index in order to maintain the invariant
- // that if the featureCompatibilityVersion is 3.4, then 'k32IncompatibleIndexSpec' index
- // exists on the "admin.system.version" collection. If we happened to fail to insert the
- // document when starting up, then on a subsequent start-up we'd no longer consider the data
- // files "clean" and would instead be in featureCompatibilityVersion=3.2.
+ // collection.
uassertStatusOK(storageInterface->insertDocument(
opCtx,
nss,
BSON("_id" << FeatureCompatibilityVersion::kParameterName
<< FeatureCompatibilityVersion::kVersionField
- << FeatureCompatibilityVersionCommandParser::kVersion34)));
+ << FeatureCompatibilityVersionCommandParser::kVersion36)));
// We then update the value of the featureCompatibilityVersion server parameter.
serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
+ ServerGlobalParams::FeatureCompatibility::Version::k36);
}
}
@@ -349,8 +245,7 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(const BSONObj& doc) {
return;
}
auto newVersion = uassertStatusOK(FeatureCompatibilityVersion::parse(doc));
- log() << "setting featureCompatibilityVersion to "
- << getFeatureCompatibilityVersionString(newVersion);
+ log() << "setting featureCompatibilityVersion to " << toString(newVersion);
serverGlobalParams.featureCompatibility.version.store(newVersion);
}
@@ -361,16 +256,16 @@ void FeatureCompatibilityVersion::onDelete(const BSONObj& doc) {
return;
}
log() << "setting featureCompatibilityVersion to "
- << FeatureCompatibilityVersionCommandParser::kVersion32;
+ << FeatureCompatibilityVersionCommandParser::kVersion34;
serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k32);
+ ServerGlobalParams::FeatureCompatibility::Version::k34);
}
void FeatureCompatibilityVersion::onDropCollection() {
log() << "setting featureCompatibilityVersion to "
- << FeatureCompatibilityVersionCommandParser::kVersion32;
+ << FeatureCompatibilityVersionCommandParser::kVersion34;
serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k32);
+ ServerGlobalParams::FeatureCompatibility::Version::k34);
}
/**
@@ -387,7 +282,7 @@ public:
virtual void append(OperationContext* opCtx, BSONObjBuilder& b, const std::string& name) {
b.append(name,
- getFeatureCompatibilityVersionString(
+ FeatureCompatibilityVersion::toString(
serverGlobalParams.featureCompatibility.version.load()));
}
@@ -395,14 +290,14 @@ public:
return Status(ErrorCodes::IllegalOperation,
str::stream() << FeatureCompatibilityVersion::kParameterName
<< " cannot be set via setParameter. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
virtual Status setFromString(const std::string& str) {
return Status(ErrorCodes::IllegalOperation,
str::stream() << FeatureCompatibilityVersion::kParameterName
<< " cannot be set via setParameter. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
} featureCompatibilityVersionParameter;
diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h
index 44029c72e21..ba28ceced17 100644
--- a/src/mongo/db/commands/feature_compatibility_version.h
+++ b/src/mongo/db/commands/feature_compatibility_version.h
@@ -31,6 +31,7 @@
#include "mongo/base/status_with.h"
#include "mongo/base/string_data.h"
#include "mongo/bson/bsonobj.h"
+#include "mongo/db/commands/feature_compatibility_version_command_parser.h"
#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/server_options.h"
@@ -47,7 +48,6 @@ extern bool internalValidateFeaturesAsMaster;
class FeatureCompatibilityVersion {
public:
- static constexpr StringData k32IncompatibleIndexName = "incompatible_with_version_32"_sd;
static constexpr StringData kCollection = "admin.system.version"_sd;
static constexpr StringData kCommandName = "setFeatureCompatibilityVersion"_sd;
static constexpr StringData kDatabase = "admin"_sd;
@@ -61,16 +61,27 @@ public:
static StatusWith<ServerGlobalParams::FeatureCompatibility::Version> parse(
const BSONObj& featureCompatibilityVersionDoc);
+ static StringData toString(ServerGlobalParams::FeatureCompatibility::Version version) {
+ switch (version) {
+ case ServerGlobalParams::FeatureCompatibility::Version::k36:
+ return FeatureCompatibilityVersionCommandParser::kVersion36;
+ case ServerGlobalParams::FeatureCompatibility::Version::k34:
+ return FeatureCompatibilityVersionCommandParser::kVersion34;
+ default:
+ MONGO_UNREACHABLE;
+ }
+ }
+
/**
* Sets the minimum allowed version in the cluster, which determines what features are
* available.
- * 'version' should be '3.4' or '3.2'.
+ * 'version' should be '3.4' or '3.6'.
*/
static void set(OperationContext* opCtx, StringData version);
/**
* If there are no non-local databases and we are not running with --shardsvr, set
- * featureCompatibilityVersion to 3.4.
+ * featureCompatibilityVersion to the latest value.
*/
static void setIfCleanStartup(OperationContext* opCtx,
repl::StorageInterface* storageInterface);
@@ -84,12 +95,12 @@ public:
/**
* Examines the _id of a document removed from admin.system.version. If it is the
- * featureCompatibilityVersion document, resets the server parameter to its default value (3.2).
+ * featureCompatibilityVersion document, resets the server parameter to its default value.
*/
static void onDelete(const BSONObj& doc);
/**
- * Resets the server parameter to its default value (3.2).
+ * Resets the server parameter to its default value.
*/
static void onDropCollection();
};
diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp
index 551ac40a758..5f80382e0f3 100644
--- a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp
@@ -38,8 +38,9 @@
namespace mongo {
-constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion34;
constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion32;
+constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion34;
+constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion36;
StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersionFromCommand(
StringData commandName, const BSONObj& cmdObj) {
@@ -58,7 +59,7 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion
<< typeName(versionElem.type())
<< " in: "
<< cmdObj
- << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility."};
+ << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility."};
}
// Ensure that the command does not contain any unrecognized parameters
@@ -72,23 +73,30 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion
ErrorCodes::InvalidOptions,
str::stream() << "Unrecognized field found " << cmdElem.fieldNameStringData() << " in "
<< cmdObj
- << ". See http ://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ << ". See http ://dochub.mongodb.org/core/3.6-feature-compatibility.");
}
const std::string version = versionElem.String();
- if (version != FeatureCompatibilityVersionCommandParser::kVersion34 &&
- version != FeatureCompatibilityVersionCommandParser::kVersion32) {
+ if (version == FeatureCompatibilityVersionCommandParser::kVersion32) {
+ return {ErrorCodes::BadValue,
+ "Invalid command argument: '3.2'. You must downgrade to MongoDB 3.4 to enable "
+ "featureCompatibilityVersion 3.2. See "
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility."};
+ }
+
+ if (version != FeatureCompatibilityVersionCommandParser::kVersion36 &&
+ version != FeatureCompatibilityVersionCommandParser::kVersion34) {
return {ErrorCodes::BadValue,
str::stream() << "Invalid command argument. Expected '"
- << FeatureCompatibilityVersionCommandParser::kVersion34
+ << FeatureCompatibilityVersionCommandParser::kVersion36
<< "' or '"
- << FeatureCompatibilityVersionCommandParser::kVersion32
+ << FeatureCompatibilityVersionCommandParser::kVersion34
<< "', found "
<< version
<< " in: "
<< cmdObj
- << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility."};
+ << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility."};
}
return version;
diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.h b/src/mongo/db/commands/feature_compatibility_version_command_parser.h
index 4e17aa94cdc..3a57f2ca75b 100644
--- a/src/mongo/db/commands/feature_compatibility_version_command_parser.h
+++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.h
@@ -43,8 +43,9 @@ public:
/**
* Known server release versions.
*/
- static constexpr StringData kVersion34 = "3.4"_sd;
static constexpr StringData kVersion32 = "3.2"_sd;
+ static constexpr StringData kVersion34 = "3.4"_sd;
+ static constexpr StringData kVersion36 = "3.6"_sd;
/**
* Interprets the specified BSON as a command and extracts the desired compatibility version
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 4b18a6fb8cb..e7d40b08c70 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -50,7 +50,6 @@
#include "mongo/db/query/get_executor.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/collection_sharding_state.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
#include "mongo/db/stats/counters.h"
@@ -148,14 +147,6 @@ public:
return qrStatus.getStatus();
}
- if (!qrStatus.getValue()->getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
// Finish the parsing step by using the QueryRequest to create a CanonicalQuery.
ExtensionsCallbackReal extensionsCallback(opCtx, &nss);
@@ -251,16 +242,6 @@ public:
auto& qr = qrStatus.getValue();
- if (!qr->getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return appendCommandStatus(
- result,
- Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."));
- }
-
// Validate term before acquiring locks, if provided.
if (auto term = qr->getReplicationTerm()) {
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp
index ac62769c96d..3b56d5074e3 100644
--- a/src/mongo/db/commands/geo_near_cmd.cpp
+++ b/src/mongo/db/commands/geo_near_cmd.cpp
@@ -52,7 +52,6 @@
#include "mongo/db/query/find_common.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/plan_summary_stats.h"
-#include "mongo/db/server_options.h"
#include "mongo/platform/unordered_map.h"
#include "mongo/util/log.h"
@@ -183,15 +182,6 @@ public:
collation = collationElt.Obj();
}
}
- if (!collation.isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return appendCommandStatus(
- result,
- Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."));
- }
long long numWanted = 100;
const char* limitName = !cmdObj["num"].eoo() ? "num" : "limit";
diff --git a/src/mongo/db/commands/group_cmd.cpp b/src/mongo/db/commands/group_cmd.cpp
index c0cccd56f6a..e66dc123214 100644
--- a/src/mongo/db/commands/group_cmd.cpp
+++ b/src/mongo/db/commands/group_cmd.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/query/find_common.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/plan_summary_stats.h"
-#include "mongo/db/server_options.h"
#include "mongo/util/log.h"
namespace mongo {
@@ -273,13 +272,6 @@ private:
if (collationEltStatus.isOK()) {
request->collation = collationElt.embeddedObject().getOwned();
}
- if (!request->collation.isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
BSONElement reduce = p["$reduce"];
if (reduce.eoo()) {
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp
index 3d2b5577388..bada0092be4 100644
--- a/src/mongo/db/commands/list_indexes.cpp
+++ b/src/mongo/db/commands/list_indexes.cpp
@@ -164,27 +164,6 @@ public:
}
MONGO_WRITE_CONFLICT_RETRY_LOOP_END(opCtx, "listIndexes", ns.ns());
- if (ns.ns() == FeatureCompatibilityVersion::kCollection &&
- indexNames[i] == FeatureCompatibilityVersion::k32IncompatibleIndexName) {
- BSONObjBuilder bob;
-
- for (auto&& indexSpecElem : indexSpec) {
- auto indexSpecElemFieldName = indexSpecElem.fieldNameStringData();
- if (indexSpecElemFieldName == IndexDescriptor::kIndexVersionFieldName) {
- // Include the index version in the command response as a decimal type
- // instead of as a 32-bit integer. This is a new BSON type that isn't
- // supported by versions of MongoDB earlier than 3.4 that will cause 3.2
- // secondaries to crash when performing initial sync.
- bob.append(IndexDescriptor::kIndexVersionFieldName,
- indexSpecElem.numberDecimal());
- } else {
- bob.append(indexSpecElem);
- }
- }
-
- indexSpec = bob.obj();
- }
-
WorkingSetID id = ws->allocate();
WorkingSetMember* member = ws->get(id);
member->keyData.clear();
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index c00d769d41d..095bcb2cef8 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
+#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
@@ -432,15 +433,12 @@ void State::prepTempCollection() {
incColl = incCtx.db()->createCollection(_opCtx, _config.incLong.ns(), options);
invariant(incColl);
- // We explicitly create a v=2 index on the "0" field so that it is always possible for a
- // user to emit() decimal keys. Since the incremental collection is not replicated to
- // any secondaries, there is no risk of inadvertently crashing an older version of
- // MongoDB when the featureCompatibilityVersion of this server is 3.2.
- BSONObj indexSpec =
+ auto rawIndexSpec =
BSON("key" << BSON("0" << 1) << "ns" << _config.incLong.ns() << "name"
- << "_temp_0"
- << "v"
- << static_cast<int>(IndexVersion::kV2));
+ << "_temp_0");
+ auto indexSpec = uassertStatusOK(index_key_validate::validateIndexSpec(
+ rawIndexSpec, _config.incLong, serverGlobalParams.featureCompatibility));
+
Status status = incColl->getIndexCatalog()
->createIndexOnEmptyCollection(_opCtx, indexSpec)
.getStatus();
@@ -1397,16 +1395,6 @@ public:
const Config config(dbname, cmd);
- if (!config.collation.isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return appendCommandStatus(
- result,
- Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."));
- }
-
LOG(1) << "mr ns: " << config.nss;
uassert(16149, "cannot run map reduce without the js engine", getGlobalScriptEngine());
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 2d9a3e9006d..3a7f1a452e1 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -33,7 +33,6 @@
#include "mongo/db/commands/run_aggregate.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/pipeline/pipeline.h"
-#include "mongo/db/server_options.h"
namespace mongo {
namespace {
@@ -86,8 +85,15 @@ public:
const BSONObj& cmdObj,
std::string& errmsg,
BSONObjBuilder& result) override {
+ const auto aggregationRequest =
+ uassertStatusOK(AggregationRequest::parseFromBSON(dbname, cmdObj, boost::none));
+
return appendCommandStatus(result,
- _runAggCommand(opCtx, dbname, cmdObj, boost::none, &result));
+ runAggregate(opCtx,
+ aggregationRequest.getNamespaceString(),
+ aggregationRequest,
+ cmdObj,
+ result));
}
Status explain(OperationContext* opCtx,
@@ -95,33 +101,11 @@ public:
const BSONObj& cmdObj,
ExplainOptions::Verbosity verbosity,
BSONObjBuilder* out) const override {
- return _runAggCommand(opCtx, dbname, cmdObj, verbosity, out);
- }
-
-private:
- static Status _runAggCommand(OperationContext* opCtx,
- const std::string& dbname,
- const BSONObj& cmdObj,
- boost::optional<ExplainOptions::Verbosity> verbosity,
- BSONObjBuilder* result) {
const auto aggregationRequest =
uassertStatusOK(AggregationRequest::parseFromBSON(dbname, cmdObj, verbosity));
- // If the featureCompatibilityVersion is 3.2, we disallow collation from the user. However,
- // operations should still respect the collection default collation. The mongos attaches the
- // collection default collation to the merger pipeline, since the merger may not have the
- // collection metadata. So the merger needs to accept a collation, and we rely on the shards
- // to reject collations from the user.
- uassert(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.",
- aggregationRequest.getCollation().isEmpty() ||
- serverGlobalParams.featureCompatibility.version.load() !=
- ServerGlobalParams::FeatureCompatibility::Version::k32 ||
- isMergePipeline(aggregationRequest.getPipeline()));
-
return runAggregate(
- opCtx, aggregationRequest.getNamespaceString(), aggregationRequest, cmdObj, *result);
+ opCtx, aggregationRequest.getNamespaceString(), aggregationRequest, cmdObj, *out);
}
} pipelineCmd;
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index 7f01ef9ca5a..19579ebe7cb 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -38,7 +38,7 @@ namespace mongo {
namespace {
/**
- * Sets the minimum allowed version for the cluster. If it is 3.2, then the node should not use 3.4
+ * Sets the minimum allowed version for the cluster. If it is 3.4, then the node should not use 3.6
* features.
*
* Format:
@@ -63,10 +63,10 @@ public:
}
virtual void help(std::stringstream& help) const {
- help << "Set the API version exposed by this node. If set to \"3.2\", then 3.4 "
- "features are disabled. If \"3.4\", then 3.4 features are enabled, and all nodes "
- "in the cluster must be version 3.4. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.";
+ help << "Set the API version exposed by this node. If set to \"3.4\", then 3.6 "
+ "features are disabled. If \"3.6\", then 3.6 features are enabled, and all nodes "
+ "in the cluster must be version 3.6. See "
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.";
}
Status checkAuthForCommand(Client* client,
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index 08696cd525e..5115a5edda6 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -116,21 +116,8 @@ Status IndexDescriptor::isIndexVersionAllowedForCreation(
case IndexVersion::kV0:
break;
case IndexVersion::kV1:
+ case IndexVersion::kV2:
return Status::OK();
- case IndexVersion::kV2: {
- if (ServerGlobalParams::FeatureCompatibility::Version::k32 ==
- featureCompatibility.version.load() &&
- featureCompatibility.validateFeaturesAsMaster.load()) {
- return {ErrorCodes::CannotCreateIndex,
- str::stream() << "Invalid index specification " << indexSpec
- << "; cannot create an index with v="
- << static_cast<int>(IndexVersion::kV2)
- << " when the featureCompatibilityVersion is 3.2. See "
- "http://dochub.mongodb.org/core/"
- "3.4-feature-compatibility."};
- }
- return Status::OK();
- }
}
return {ErrorCodes::CannotCreateIndex,
str::stream() << "Invalid index specification " << indexSpec
@@ -140,23 +127,6 @@ Status IndexDescriptor::isIndexVersionAllowedForCreation(
IndexVersion IndexDescriptor::getDefaultIndexVersion(
ServerGlobalParams::FeatureCompatibility::Version featureCompatibilityVersion) {
- ServerGlobalParams::FeatureCompatibility featureCompatibility;
- featureCompatibility.version.store(featureCompatibilityVersion);
- // We always pass validateFeaturesAsMaster=true since this flag should not affect our
- // determination of the default index version.
- featureCompatibility.validateFeaturesAsMaster.store(true);
- // We pass in an empty object for the index specification because it is only used within the
- // error reason.
- if (!IndexDescriptor::isIndexVersionAllowedForCreation(
- IndexVersion::kV2, featureCompatibility, BSONObj())
- .isOK()) {
- // When the featureCompatibilityVersion is 3.2, we use index version v=1 as the default
- // index version.
- return IndexVersion::kV1;
- }
-
- // When the featureCompatibilityVersion is 3.4, we use index version v=2 as the default index
- // version.
return IndexVersion::kV2;
}
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp
index e53988ea78e..61c3fedf474 100644
--- a/src/mongo/db/ops/parsed_delete.cpp
+++ b/src/mongo/db/ops/parsed_delete.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/query_planner_common.h"
#include "mongo/db/repl/replication_coordinator_global.h"
-#include "mongo/db/server_options.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -61,14 +60,6 @@ Status ParsedDelete::parseRequest() {
// DeleteStage would not return the deleted document.
invariant(_request->getProj().isEmpty() || _request->shouldReturnDeleted());
- if (!_request->getCollation().isEmpty() &&
- serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
if (CanonicalQuery::isSimpleIdQuery(_request->getQuery())) {
return Status::OK();
}
diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp
index a6dfb2373ac..2d3de40342a 100644
--- a/src/mongo/db/ops/parsed_update.cpp
+++ b/src/mongo/db/ops/parsed_update.cpp
@@ -35,7 +35,6 @@
#include "mongo/db/query/canonical_query.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
#include "mongo/db/query/query_planner_common.h"
-#include "mongo/db/server_options.h"
namespace mongo {
@@ -52,13 +51,6 @@ Status ParsedUpdate::parseRequest() {
invariant(_request->getProj().isEmpty() || _request->shouldReturnAnyDocs());
if (!_request->getCollation().isEmpty()) {
- if (serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32) {
- return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.4 to use collation. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
auto collator = CollatorFactoryInterface::get(_opCtx->getServiceContext())
->makeFromBSON(_request->getCollation());
if (!collator.isOK()) {
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index d91a80a58d9..44ad19fda7b 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -282,16 +282,73 @@ public:
opCtx->getClient(), std::move(swParseClientMetadata.getValue()));
}
+ // Parse the optional 'internalClient' field. This is provided by incoming connections from
+ // mongod and mongos.
+ auto internalClientElement = cmdObj["internalClient"];
+ if (internalClientElement) {
+ auto session = opCtx->getClient()->session();
+ if (session) {
+ session->replaceTags(session->getTags() | transport::Session::kInternalClient);
+ }
+
+ uassert(ErrorCodes::TypeMismatch,
+ str::stream() << "'internalClient' must be of type Object, but was of type "
+ << typeName(internalClientElement.type()),
+ internalClientElement.type() == BSONType::Object);
+
+ bool foundMaxWireVersion = false;
+ for (auto&& elem : internalClientElement.Obj()) {
+ auto fieldName = elem.fieldNameStringData();
+ if (fieldName == "minWireVersion") {
+ // We do not currently use 'internalClient.minWireVersion'.
+ continue;
+ } else if (fieldName == "maxWireVersion") {
+ foundMaxWireVersion = true;
+
+ uassert(ErrorCodes::TypeMismatch,
+ str::stream() << "'maxWireVersion' field of 'internalClient' must be "
+ "of type int, but was of type "
+ << typeName(elem.type()),
+ elem.type() == BSONType::NumberInt);
+
+ // All incoming connections from mongod/mongos of earlier versions should be
+ // closed if the featureCompatibilityVersion is bumped to 3.6.
+ if (elem.numberInt() >= WireSpec::instance().incoming.maxWireVersion) {
+ if (session) {
+ session->replaceTags(
+ session->getTags() |
+ transport::Session::kLatestVersionInternalClientKeepOpen);
+ }
+ } else {
+ if (session) {
+ session->replaceTags(
+ session->getTags() &
+ ~transport::Session::kLatestVersionInternalClientKeepOpen);
+ }
+ }
+ } else {
+ uasserted(ErrorCodes::BadValue,
+ str::stream() << "Unrecognized field of 'internalClient': '"
+ << fieldName
+ << "'");
+ }
+ }
+
+ uassert(ErrorCodes::BadValue,
+ "Missing required field 'maxWireVersion' of 'internalClient'",
+ foundMaxWireVersion);
+ } else {
+ auto session = opCtx->getClient()->session();
+ if (session && !(session->getTags() & transport::Session::kInternalClient)) {
+ session->replaceTags(session->getTags() |
+ transport::Session::kExternalClientKeepOpen);
+ }
+ }
+
appendReplicationInfo(opCtx, result, 0);
if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) {
- // If we have feature compatibility version 3.4, use a config server mode that 3.2
- // mongos won't understand. This should prevent a 3.2 mongos from joining the cluster or
- // making a connection to the config servers.
- int configServerModeNumber = (serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k34)
- ? 2
- : 1;
+ const int configServerModeNumber = 2;
result.append("configsvr", configServerModeNumber);
}
@@ -300,7 +357,18 @@ public:
result.appendNumber("maxWriteBatchSize", BatchedCommandRequest::kMaxWriteBatchSize);
result.appendDate("localTime", jsTime());
result.append("maxWireVersion", WireSpec::instance().incoming.maxWireVersion);
- result.append("minWireVersion", WireSpec::instance().incoming.minWireVersion);
+
+ // If the featureCompatibilityVersion is 3.6, respond with minWireVersion=maxWireVersion.
+ // Then if the connection is from a mongod/mongos of an earlier version, it will fail to
+ // connect.
+ if (internalClientElement &&
+ serverGlobalParams.featureCompatibility.version.load() ==
+ ServerGlobalParams::FeatureCompatibility::Version::k36) {
+ result.append("minWireVersion", WireSpec::instance().incoming.maxWireVersion);
+ } else {
+ result.append("minWireVersion", WireSpec::instance().incoming.minWireVersion);
+ }
+
result.append("readOnly", storageGlobalParams.readOnly);
const auto parameter = mapFindWithDefault(ServerParameterSet::getGlobal()->getMap(),
diff --git a/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp b/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp
index 91e5ba98f2d..a70c7406e59 100644
--- a/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp
@@ -56,7 +56,7 @@ public:
void help(std::stringstream& help) const override {
help << "Internal command, which is exported by the sharding config server. Do not call "
"directly. Sets featureCompatibilityVersion on all shards. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.";
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.";
}
bool slaveOk() const override {
@@ -92,7 +92,7 @@ public:
uassert(ErrorCodes::IllegalOperation,
str::stream() << getName()
<< " can only be run on config servers. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.",
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
// Forward to all shards.
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h
index c858964bcd4..148c96dd0bd 100644
--- a/src/mongo/db/server_options.h
+++ b/src/mongo/db/server_options.h
@@ -141,21 +141,20 @@ struct ServerGlobalParams {
struct FeatureCompatibility {
enum class Version {
/**
- * In this mode, the cluster will expose a 3.2-like API. Attempts by a client to use new
- * features in 3.4, such as read-only views, collation, or the decimal128 BSON type,
- * will be rejected.
+ * In this mode, the cluster will expose a 3.4-like API. Attempts by a client to use new
+ * features in 3.6 will be rejected.
*/
- k32,
+ k34,
/**
- * In this mode, new features in 3.4 are allowed. The system should guarantee that no
- * 3.2 node can participate in a cluster whose feature compatibility version is 3.4.
+ * In this mode, new features in 3.6 are allowed. The system should guarantee that no
+ * 3.4 node can participate in a cluster whose feature compatibility version is 3.6.
*/
- k34,
+ k36,
};
// Read-only parameter featureCompatibilityVersion.
- AtomicWord<Version> version{Version::k32};
+ AtomicWord<Version> version{Version::k34};
// 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
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
index f5acb385121..9759b056264 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
@@ -207,8 +207,7 @@ StatusWith<std::string> WiredTigerIndex::generateCreateString(const std::string&
}
ss << ",value_format=u";
- // We build v=2 indexes when the featureCompatibilityVersion is 3.4. This means that the server
- // supports new index features and we can therefore use KeyString::Version::V1.
+ // Index versions greater than 2 use KeyString version 1.
const int keyStringVersion = desc.version() >= IndexDescriptor::IndexVersion::kV2
? kKeyStringV1Version
: kKeyStringV0Version;
diff --git a/src/mongo/db/views/view_catalog.cpp b/src/mongo/db/views/view_catalog.cpp
index 7f810dcaf25..7fe8d85c9d9 100644
--- a/src/mongo/db/views/view_catalog.cpp
+++ b/src/mongo/db/views/view_catalog.cpp
@@ -46,7 +46,6 @@
#include "mongo/db/pipeline/lite_parsed_pipeline.h"
#include "mongo/db/pipeline/pipeline.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/storage/recovery_unit.h"
#include "mongo/db/views/resolved_view.h"
@@ -262,14 +261,6 @@ Status ViewCatalog::createView(OperationContext* opCtx,
const BSONObj& collation) {
stdx::lock_guard<stdx::mutex> lk(_mutex);
- if (serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32 &&
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load()) {
- return Status(ErrorCodes::CommandNotSupported,
- "Cannot create view when the featureCompatibilityVersion is 3.2. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
if (viewName.db() != viewOn.db())
return Status(ErrorCodes::BadValue,
"View must be created on a view or collection in the same database");
@@ -300,14 +291,6 @@ Status ViewCatalog::modifyView(OperationContext* opCtx,
const BSONArray& pipeline) {
stdx::lock_guard<stdx::mutex> lk(_mutex);
- if (serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k32 &&
- serverGlobalParams.featureCompatibility.validateFeaturesAsMaster.load()) {
- return Status(ErrorCodes::CommandNotSupported,
- "Cannot modify view when the featureCompatibilityVersion is 3.2. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
- }
-
if (viewName.db() != viewOn.db())
return Status(ErrorCodes::BadValue,
"View must be created on a view or collection in the same database");
diff --git a/src/mongo/db/views/view_catalog_test.cpp b/src/mongo/db/views/view_catalog_test.cpp
index f1708bef504..3e284372735 100644
--- a/src/mongo/db/views/view_catalog_test.cpp
+++ b/src/mongo/db/views/view_catalog_test.cpp
@@ -39,7 +39,6 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/query/query_test_service_context.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/service_context_noop.h"
#include "mongo/db/views/durable_view_catalog.h"
#include "mongo/db/views/view.h"
@@ -68,13 +67,6 @@ constexpr auto kLargeString =
const auto kOneKiBMatchStage = BSON("$match" << BSON("data" << kLargeString));
const auto kTinyMatchStage = BSON("$match" << BSONObj());
-MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion34, ("EndStartupOptionStorage"))
-(InitializerContext* context) {
- mongo::serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
- return Status::OK();
-}
-
class DurableViewCatalogDummy final : public DurableViewCatalog {
public:
explicit DurableViewCatalogDummy() : _upsertCount(0), _iterateCount(0) {}
diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp
index 70222426d1b..b83d109906d 100644
--- a/src/mongo/dbtests/dbtests.cpp
+++ b/src/mongo/dbtests/dbtests.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/logical_clock.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_d.h"
#include "mongo/db/wire_version.h"
@@ -61,12 +60,6 @@ namespace mongo {
namespace dbtests {
namespace {
const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2;
-
-MONGO_INITIALIZER(FeatureCompatibilityVersionForTest)(InitializerContext* context) {
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
- return Status::OK();
-}
} // namespace
void initWireSpec() {
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp
index 8ba67219d91..78ec85296f9 100644
--- a/src/mongo/dbtests/jstests.cpp
+++ b/src/mongo/dbtests/jstests.cpp
@@ -789,11 +789,6 @@ public:
class NumberDecimal {
public:
void run() {
- // Set the featureCompatibilityVersion to 3.4 so that BSON validation always uses
- // BSONVersion::kLatest.
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
-
unique_ptr<Scope> s(getGlobalScriptEngine()->newScope());
BSONObjBuilder b;
Decimal128 val = Decimal128("2.010");
@@ -823,11 +818,6 @@ public:
class NumberDecimalGetFromScope {
public:
void run() {
- // Set the featureCompatibilityVersion to 3.4 so that BSON validation always uses
- // BSONVersion::kLatest.
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
-
unique_ptr<Scope> s(getGlobalScriptEngine()->newScope());
ASSERT(s->exec("a = 5;", "a", false, true, false));
ASSERT_TRUE(Decimal128(5).isEqual(s->getNumberDecimal("a")));
@@ -837,11 +827,6 @@ public:
class NumberDecimalBigObject {
public:
void run() {
- // Set the featureCompatibilityVersion to 3.4 so that BSON validation always uses
- // BSONVersion::kLatest.
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
-
unique_ptr<Scope> s(getGlobalScriptEngine()->newScope());
BSONObj in;
@@ -1136,11 +1121,6 @@ public:
void run() {
// Insert in Javascript -> Find using DBDirectClient
- // Set the featureCompatibilityVersion to 3.4 so that BSON validation always uses
- // BSONVersion::kLatest.
- serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
-
// Drop the collection
const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext();
OperationContext& opCtx = *opCtxPtr;
diff --git a/src/mongo/rpc/object_check.h b/src/mongo/rpc/object_check.h
index 7c7741ada62..2a6e485097c 100644
--- a/src/mongo/rpc/object_check.h
+++ b/src/mongo/rpc/object_check.h
@@ -45,19 +45,10 @@ class Status;
template <>
struct Validator<BSONObj> {
inline static BSONVersion enabledBSONVersion() {
- // 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;
+ // The enabled BSON version is always the latest BSON version if no new BSON types have been
+ // added during the release. Otherwise, the BSON version returned should be controlled
+ // through the featureCompatibilityVersion.
+ return BSONVersion::kLatest;
}
inline static Status validateLoad(const char* ptr, size_t length) {
diff --git a/src/mongo/rpc/protocol.cpp b/src/mongo/rpc/protocol.cpp
index 604dc708b52..ada7e8f2cee 100644
--- a/src/mongo/rpc/protocol.cpp
+++ b/src/mongo/rpc/protocol.cpp
@@ -174,12 +174,6 @@ StatusWith<ProtocolSetAndWireVersionInfo> parseProtocolSetFromIsMasterReply(
return {{protos, version}};
}
-bool supportsWireVersionForOpCommandInMongod(const WireVersionInfo version) {
- // FIND_COMMAND versions support OP_COMMAND (in mongod but not mongos).
- return (version.minWireVersion <= WireVersion::FIND_COMMAND) &&
- (version.maxWireVersion >= WireVersion::FIND_COMMAND);
-}
-
ProtocolSet computeProtocolSet(const WireVersionInfo version) {
ProtocolSet result = supports::kNone;
if (version.minWireVersion <= version.maxWireVersion) {
diff --git a/src/mongo/rpc/protocol.h b/src/mongo/rpc/protocol.h
index 57cb491bf5c..c7500761e98 100644
--- a/src/mongo/rpc/protocol.h
+++ b/src/mongo/rpc/protocol.h
@@ -138,11 +138,6 @@ StatusWith<ProtocolSetAndWireVersionInfo> parseProtocolSetFromIsMasterReply(
const BSONObj& isMasterReply);
/**
- * Returns true if wire version supports OP_COMMAND in mongod (not mongos).
- */
-bool supportsWireVersionForOpCommandInMongod(const WireVersionInfo version);
-
-/**
* Computes supported protocols from wire versions.
*/
ProtocolSet computeProtocolSet(const WireVersionInfo version);
diff --git a/src/mongo/s/catalog/sharding_catalog_add_shard_test.cpp b/src/mongo/s/catalog/sharding_catalog_add_shard_test.cpp
index a5b77cbd5aa..1c4dbe69bc9 100644
--- a/src/mongo/s/catalog/sharding_catalog_add_shard_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_add_shard_test.cpp
@@ -132,6 +132,19 @@ protected:
});
}
+ void expectSetFeatureCompatibilityVersion(const HostAndPort& target,
+ StatusWith<BSONObj> response) {
+ onCommandForAddShard([&, target, response](const RemoteCommandRequest& request) {
+ ASSERT_EQ(request.target, target);
+ ASSERT_EQ(request.dbname, "admin");
+ ASSERT_BSONOBJ_EQ(request.cmdObj,
+ BSON("setFeatureCompatibilityVersion"
+ << "3.4"));
+
+ return response;
+ });
+ }
+
/**
* Waits for a request for the shardIdentity document to be upserted into a shard from the
* config server on addShard.
@@ -404,6 +417,9 @@ TEST_F(AddShardTest, StandaloneBasicSuccess) {
BSON("name" << discoveredDB1.getName() << "sizeOnDisk" << 2000),
BSON("name" << discoveredDB2.getName() << "sizeOnDisk" << 5000)});
+ // The shard receives the setFeatureCompatibilityVersion command.
+ expectSetFeatureCompatibilityVersion(shardTarget, BSON("ok" << 1));
+
// The shardIdentity doc inserted into the admin.system.version collection on the shard.
expectShardIdentityUpsertReturnSuccess(shardTarget, expectedShardName);
@@ -483,6 +499,9 @@ TEST_F(AddShardTest, StandaloneGenerateName) {
BSON("name" << discoveredDB1.getName() << "sizeOnDisk" << 2000),
BSON("name" << discoveredDB2.getName() << "sizeOnDisk" << 5000)});
+ // The shard receives the setFeatureCompatibilityVersion command.
+ expectSetFeatureCompatibilityVersion(shardTarget, BSON("ok" << 1));
+
// The shardIdentity doc inserted into the admin.system.version collection on the shard.
expectShardIdentityUpsertReturnSuccess(shardTarget, expectedShardName);
@@ -896,6 +915,9 @@ TEST_F(AddShardTest, SuccessfullyAddReplicaSet) {
// Get databases list from new shard
expectListDatabases(shardTarget, std::vector<BSONObj>{BSON("name" << discoveredDB.getName())});
+ // The shard receives the setFeatureCompatibilityVersion command.
+ expectSetFeatureCompatibilityVersion(shardTarget, BSON("ok" << 1));
+
// The shardIdentity doc inserted into the admin.system.version collection on the shard.
expectShardIdentityUpsertReturnSuccess(shardTarget, expectedShardName);
@@ -958,6 +980,9 @@ TEST_F(AddShardTest, ReplicaSetExtraHostsDiscovered) {
// Get databases list from new shard
expectListDatabases(shardTarget, std::vector<BSONObj>{BSON("name" << discoveredDB.getName())});
+ // The shard receives the setFeatureCompatibilityVersion command.
+ expectSetFeatureCompatibilityVersion(shardTarget, BSON("ok" << 1));
+
// The shardIdentity doc inserted into the admin.system.version collection on the shard.
expectShardIdentityUpsertReturnSuccess(shardTarget, expectedShardName);
@@ -1034,6 +1059,9 @@ TEST_F(AddShardTest, AddShardSucceedsEvenIfAddingDBsFromNewShardFails) {
BSON("name" << discoveredDB1.getName() << "sizeOnDisk" << 2000),
BSON("name" << discoveredDB2.getName() << "sizeOnDisk" << 5000)});
+ // The shard receives the setFeatureCompatibilityVersion command.
+ expectSetFeatureCompatibilityVersion(shardTarget, BSON("ok" << 1));
+
// The shardIdentity doc inserted into the admin.system.version collection on the shard.
expectShardIdentityUpsertReturnSuccess(shardTarget, expectedShardName);
diff --git a/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp b/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp
index 6d5ee674f5c..c43cfe3a8aa 100644
--- a/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_config_initialization_test.cpp
@@ -262,64 +262,64 @@ TEST_F(ConfigInitializationTest, BuildsNecessaryIndexes) {
ASSERT_OK(catalogManager()->initializeConfigDatabaseIfNeeded(operationContext()));
auto expectedChunksIndexes = std::vector<BSONObj>{
- BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
<< "ns"
<< "config.chunks"),
- BSON("v" << 1 << "unique" << true << "key" << BSON("ns" << 1 << "min" << 1) << "name"
+ BSON("v" << 2 << "unique" << true << "key" << BSON("ns" << 1 << "min" << 1) << "name"
<< "ns_1_min_1"
<< "ns"
<< "config.chunks"),
- BSON("v" << 1 << "unique" << true << "key" << BSON("ns" << 1 << "shard" << 1 << "min" << 1)
+ BSON("v" << 2 << "unique" << true << "key" << BSON("ns" << 1 << "shard" << 1 << "min" << 1)
<< "name"
<< "ns_1_shard_1_min_1"
<< "ns"
<< "config.chunks"),
- BSON("v" << 1 << "unique" << true << "key" << BSON("ns" << 1 << "lastmod" << 1) << "name"
+ BSON("v" << 2 << "unique" << true << "key" << BSON("ns" << 1 << "lastmod" << 1) << "name"
<< "ns_1_lastmod_1"
<< "ns"
<< "config.chunks")};
auto expectedLockpingsIndexes =
- std::vector<BSONObj>{BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
+ std::vector<BSONObj>{BSON("v" << 2 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
<< "ns"
<< "config.lockpings"),
- BSON("v" << 1 << "key" << BSON("ping" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("ping" << 1) << "name"
<< "ping_1"
<< "ns"
<< "config.lockpings")};
auto expectedLocksIndexes = std::vector<BSONObj>{
- BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
<< "ns"
<< "config.locks"),
- BSON("v" << 1 << "key" << BSON("ts" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("ts" << 1) << "name"
<< "ts_1"
<< "ns"
<< "config.locks"),
- BSON("v" << 1 << "key" << BSON("state" << 1 << "process" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("state" << 1 << "process" << 1) << "name"
<< "state_1_process_1"
<< "ns"
<< "config.locks")};
auto expectedShardsIndexes = std::vector<BSONObj>{
- BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
<< "ns"
<< "config.shards"),
- BSON("v" << 1 << "unique" << true << "key" << BSON("host" << 1) << "name"
+ BSON("v" << 2 << "unique" << true << "key" << BSON("host" << 1) << "name"
<< "host_1"
<< "ns"
<< "config.shards")};
auto expectedTagsIndexes = std::vector<BSONObj>{
- BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
<< "ns"
<< "config.tags"),
- BSON("v" << 1 << "unique" << true << "key" << BSON("ns" << 1 << "min" << 1) << "name"
+ BSON("v" << 2 << "unique" << true << "key" << BSON("ns" << 1 << "min" << 1) << "name"
<< "ns_1_min_1"
<< "ns"
<< "config.tags"),
- BSON("v" << 1 << "key" << BSON("ns" << 1 << "tag" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("ns" << 1 << "tag" << 1) << "name"
<< "ns_1_tag_1"
<< "ns"
<< "config.tags")};
@@ -352,11 +352,11 @@ TEST_F(ConfigInitializationTest, CompatibleIndexAlreadyExists) {
ASSERT_OK(catalogManager()->initializeConfigDatabaseIfNeeded(operationContext()));
auto expectedShardsIndexes = std::vector<BSONObj>{
- BSON("v" << 1 << "key" << BSON("_id" << 1) << "name"
+ BSON("v" << 2 << "key" << BSON("_id" << 1) << "name"
<< "_id_"
<< "ns"
<< "config.shards"),
- BSON("v" << 1 << "unique" << true << "key" << BSON("host" << 1) << "name"
+ BSON("v" << 2 << "unique" << true << "key" << BSON("host" << 1) << "name"
<< "host_1"
<< "ns"
<< "config.shards")};
diff --git a/src/mongo/s/catalog/sharding_catalog_manager_shard_operations_impl.cpp b/src/mongo/s/catalog/sharding_catalog_manager_shard_operations_impl.cpp
index 2a2d6b1d3d9..674cba90727 100644
--- a/src/mongo/s/catalog/sharding_catalog_manager_shard_operations_impl.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_manager_shard_operations_impl.cpp
@@ -617,29 +617,19 @@ StatusWith<std::string> ShardingCatalogManagerImpl::addShard(
shardType.setMaxSizeMB(maxSize);
}
- // If the minimum allowed version for the cluster is 3.4, set the featureCompatibilityVersion to
- // 3.4 on the shard.
- if (serverGlobalParams.featureCompatibility.version.load() ==
- ServerGlobalParams::FeatureCompatibility::Version::k34) {
- auto versionResponse =
- _runCommandForAddShard(opCtx,
- targeter.get(),
- "admin",
- BSON(FeatureCompatibilityVersion::kCommandName
- << FeatureCompatibilityVersionCommandParser::kVersion34));
- if (!versionResponse.isOK()) {
- return versionResponse.getStatus();
- }
+ // The featureCompatibilityVersion should be the same throughout the cluster.
+ auto versionResponse = _runCommandForAddShard(
+ opCtx,
+ targeter.get(),
+ "admin",
+ BSON(FeatureCompatibilityVersion::kCommandName << FeatureCompatibilityVersion::toString(
+ serverGlobalParams.featureCompatibility.version.load())));
+ if (!versionResponse.isOK()) {
+ return versionResponse.getStatus();
+ }
- if (!versionResponse.getValue().commandStatus.isOK()) {
- if (versionResponse.getStatus().code() == ErrorCodes::CommandNotFound) {
- return {ErrorCodes::OperationFailed,
- "featureCompatibilityVersion for cluster is 3.4, cannot add a shard with "
- "version below 3.4. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility."};
- }
- return versionResponse.getValue().commandStatus;
- }
+ if (!versionResponse.getValue().commandStatus.isOK()) {
+ return versionResponse.getValue().commandStatus;
}
if (!MONGO_FAIL_POINT(dontUpsertShardIdentityOnNewShards)) {
diff --git a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
index 9782f1f05bf..de864f2d44f 100644
--- a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
+++ b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
@@ -40,7 +40,7 @@ namespace mongo {
namespace {
/**
- * Sets the minimum allowed version for the cluster. If it is 3.2, then shards should not use 3.4
+ * Sets the minimum allowed version for the cluster. If it is 3.4, then shards should not use 3.6
* features.
*
* Format:
@@ -65,10 +65,10 @@ public:
}
virtual void help(std::stringstream& help) const {
- help << "Set the API version for the cluster. If set to \"3.2\", then 3.4 features are "
- "disabled. If \"3.4\", then 3.4 features are enabled, and all nodes in the cluster "
- "must be version 3.4. See "
- "http://dochub.mongodb.org/core/3.4-feature-compatibility.";
+ help << "Set the API version for the cluster. If set to \"3.4\", then 3.6 features are "
+ "disabled. If \"3.6\", then 3.6 features are enabled, and all nodes in the cluster "
+ "must be version 3.6. See "
+ "http://dochub.mongodb.org/core/3.6-feature-compatibility.";
}
Status checkAuthForCommand(Client* client,
diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp
index 93f1ad59b28..e663ea15a26 100644
--- a/src/mongo/s/server.cpp
+++ b/src/mongo/s/server.cpp
@@ -361,12 +361,12 @@ MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default"))
}
} // namespace
-// We set the featureCompatibilityVersion to 3.4 in the mongos so that BSON validation always uses
-// BSONVersion::kLatest.
-MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion34, ("EndStartupOptionStorage"))
+// We set the featureCompatibilityVersion to 3.6 in the mongos and rely on the shards to reject
+// usages of new features if their featureCompatibilityVersion is lower.
+MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion36, ("EndStartupOptionStorage"))
(InitializerContext* context) {
mongo::serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
+ ServerGlobalParams::FeatureCompatibility::Version::k36);
return Status::OK();
}
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 7e1703072ef..16f16be7c56 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -90,12 +90,12 @@ static AtomicBool atPrompt(false); // can eval before getting to prompt
namespace {
const auto kDefaultMongoURL = "mongodb://127.0.0.1:27017"_sd;
-// We set the featureCompatibilityVersion to 3.4 in the mongo shell so that BSON validation always
-// uses BSONVersion::kLatest.
-MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion34, ("EndStartupOptionSetup"))
+// We set the featureCompatibilityVersion to 3.6 in the mongo shell and rely on the server to reject
+// usages of new features if its featureCompatibilityVersion is lower.
+MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersion36, ("EndStartupOptionSetup"))
(InitializerContext* context) {
mongo::serverGlobalParams.featureCompatibility.version.store(
- ServerGlobalParams::FeatureCompatibility::Version::k34);
+ ServerGlobalParams::FeatureCompatibility::Version::k36);
return Status::OK();
}
}
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
index b95480acf07..41bff90dd06 100644
--- a/src/mongo/shell/shardingtest.js
+++ b/src/mongo/shell/shardingtest.js
@@ -1004,7 +1004,7 @@ var ShardingTest = function(params) {
* be manually changed if and when there is a new feature compatibility version.
*/
function _hasNewFeatureCompatibilityVersion() {
- return false;
+ return true;
}
// ShardingTest initialization
@@ -1313,9 +1313,7 @@ var ShardingTest = function(params) {
var csrsPrimary = this.configRS.getPrimary();
// If 'otherParams.mongosOptions.binVersion' is an array value, then we'll end up constructing a
- // version iterator. We initialize the options for the mongos processes before checking whether
- // we need to run {setFeatureCompatibilityVersion: "3.2"} on the CSRS primary so we know
- // definitively what binVersions will be used for the mongos processes.
+ // version iterator.
const mongosOptions = [];
for (var i = 0; i < numMongos; ++i) {
let options = {
@@ -1335,19 +1333,11 @@ var ShardingTest = function(params) {
options.port = options.port || allocatePort();
- // TODO(esha): remove after v3.4 ships.
- // Legacy mongoses use a command line option to disable autosplit instead of reading the
- // config.settings collection.
- if (options.binVersion && MongoRunner.areBinVersionsTheSame('3.2', options.binVersion) &&
- !otherParams.enableAutoSplit) {
- options.noAutoSplit = "";
- }
-
mongosOptions.push(options);
}
const configRS = this.configRS;
- if (_hasNewFeatureCompatibilityVersion && _isMixedVersionCluster()) {
+ if (_hasNewFeatureCompatibilityVersion() && _isMixedVersionCluster()) {
function setFeatureCompatibilityVersion() {
assert.commandWorked(csrsPrimary.adminCommand({setFeatureCompatibilityVersion: '3.4'}));
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index 216217ed0b2..2cb79d743ab 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -229,8 +229,6 @@ jsTestOptions = function() {
shardMixedBinVersions: TestData.shardMixedBinVersions || false,
networkMessageCompressors: TestData.networkMessageCompressors,
skipValidationOnInvalidViewDefinitions: TestData.skipValidationOnInvalidViewDefinitions,
- forceValidationWithFeatureCompatibilityVersion:
- TestData.forceValidationWithFeatureCompatibilityVersion,
skipCollectionAndIndexValidation: TestData.skipCollectionAndIndexValidation,
skipValidationOnNamespaceNotFound: TestData.skipValidationOnNamespaceNotFound
});
diff --git a/src/mongo/transport/session.h b/src/mongo/transport/session.h
index e82cd3d8faf..2cfae3815f2 100644
--- a/src/mongo/transport/session.h
+++ b/src/mongo/transport/session.h
@@ -69,6 +69,9 @@ public:
static constexpr TagMask kEmptyTagMask = 0;
static constexpr TagMask kKeepOpen = 1;
+ static constexpr TagMask kInternalClient = 2;
+ static constexpr TagMask kLatestVersionInternalClientKeepOpen = 4;
+ static constexpr TagMask kExternalClientKeepOpen = 8;
/**
* Destroys a session, calling end() for this session in its TransportLayer.