diff options
author | Blake Oler <blake.oler@mongodb.com> | 2018-04-04 20:08:43 -0400 |
---|---|---|
committer | Blake Oler <blake.oler@mongodb.com> | 2018-04-05 11:21:30 -0400 |
commit | 2f908a5d5ce7c7238807ca24b4090ac8920bdf8c (patch) | |
tree | 60b321d11269df4cc3141d48450c1ef6885d90ee /src | |
parent | 657fdff7b50949b50848b1de466c88f7be18034b (diff) | |
download | mongo-2f908a5d5ce7c7238807ca24b4090ac8920bdf8c.tar.gz |
SERVER-34323 Add DatabaseVersion field to unsharded databases when adding shard to cluster on FCV 4.0
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp index 2ee60c2011d..77c112a7eec 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp @@ -67,6 +67,7 @@ #include "mongo/s/cluster_identity_loader.h" #include "mongo/s/grid.h" #include "mongo/s/shard_util.h" +#include "mongo/s/versioning.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/util/fail_point_service.h" @@ -700,6 +701,15 @@ StatusWith<std::string> ShardingCatalogManager::addShard( // Add all databases which were discovered on the new shard for (const auto& dbName : dbNamesStatus.getValue()) { DatabaseType dbt(dbName, shardType.getName(), false); + + // If we're in FCV 4.0, we should add a version to each database. + if (serverGlobalParams.featureCompatibility.getVersion() == + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo40 || + serverGlobalParams.featureCompatibility.getVersion() == + ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo40) { + dbt.setVersion(Versioning::newDatabaseVersion()); + } + Status status = Grid::get(opCtx)->catalogClient()->updateDatabase(opCtx, dbName, dbt); if (!status.isOK()) { log() << "adding shard " << shardConnectionString.toString() |