diff options
author | Jordi Serra Torrens <jordi.serra-torrens@mongodb.com> | 2021-02-25 09:25:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-25 15:17:51 +0000 |
commit | 3a71f0a8f695e974dfe383fbcfebb69f5985761c (patch) | |
tree | 800256998817956a6b5cd886f3fbc38d0cc9c174 | |
parent | ae1be164b0929507b886d46a409f5a1a97e773ee (diff) | |
download | mongo-3a71f0a8f695e974dfe383fbcfebb69f5985761c.tar.gz |
SERVER-54788: Hold the ShardingRoutingInfoFormatStability distLock in setFCV command until the shards have fully upgraded
-rw-r--r-- | src/mongo/db/commands/set_feature_compatibility_version_command.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager.cpp | 13 |
2 files changed, 15 insertions, 13 deletions
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 47205b618b6..e3dff7d6962 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -55,6 +55,7 @@ #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/s/active_migrations_registry.h" #include "mongo/db/s/config/sharding_catalog_manager.h" +#include "mongo/db/s/dist_lock_manager.h" #include "mongo/db/s/migration_util.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/server_options.h" @@ -315,6 +316,13 @@ public: } if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { + DistLockManager::ScopedDistLock dbDistLock( + uassertStatusOK(DistLockManager::get(opCtx)->lock( + opCtx, + DistLockManager::kShardingRoutingInfoFormatStabilityLockName, + "fcvUpgrade", + DistLockManager::kDefaultLockTimeout))); + if (requestedVersion >= FeatureCompatibilityParams::Version::kVersion49) { // SERVER-52630: Remove once 5.0 becomes the LastLTS ShardingCatalogManager::get(opCtx)->removePre49LegacyMetadata(opCtx); @@ -422,6 +430,13 @@ public: return false; if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { + DistLockManager::ScopedDistLock dbDistLock( + uassertStatusOK(DistLockManager::get(opCtx)->lock( + opCtx, + DistLockManager::kShardingRoutingInfoFormatStabilityLockName, + "fcvDowngrade", + DistLockManager::kDefaultLockTimeout))); + // Downgrade metadata created in FCV 4.9. // TODO SERVER-53283: Remove once 5.0 has been released. if (requestedVersion < FeatureCompatibilityParams::Version::kVersion49) { diff --git a/src/mongo/db/s/config/sharding_catalog_manager.cpp b/src/mongo/db/s/config/sharding_catalog_manager.cpp index a35d3fd56ff..abf8bbc12ac 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager.cpp @@ -42,7 +42,6 @@ #include "mongo/db/ops/write_ops.h" #include "mongo/db/query/query_request_helper.h" #include "mongo/db/s/balancer/type_migration.h" -#include "mongo/db/s/dist_lock_manager.h" #include "mongo/db/s/type_lockpings.h" #include "mongo/db/s/type_locks.h" #include "mongo/db/vector_clock.h" @@ -688,12 +687,6 @@ void ShardingCatalogManager::_upgradeCollectionsAndChunksMetadataFor49(Operation auto const catalogCache = Grid::get(opCtx)->catalogCache(); auto const configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); - DistLockManager::ScopedDistLock dbDistLock(uassertStatusOK(DistLockManager::get(opCtx)->lock( - opCtx, - DistLockManager::kShardingRoutingInfoFormatStabilityLockName, - "fcvUpgrade", - DistLockManager::kDefaultLockTimeout))); - auto collectionDocs = uassertStatusOK( configShard->exhaustiveFindOnConfig( @@ -803,12 +796,6 @@ void ShardingCatalogManager::_downgradeCollectionsAndChunksMetadataToPre49( auto const catalogCache = Grid::get(opCtx)->catalogCache(); auto const configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); - DistLockManager::ScopedDistLock dbDistLock(uassertStatusOK(DistLockManager::get(opCtx)->lock( - opCtx, - DistLockManager::kShardingRoutingInfoFormatStabilityLockName, - "fcvDowngrade", - DistLockManager::kDefaultLockTimeout))); - auto collectionDocs = uassertStatusOK( configShard->exhaustiveFindOnConfig( |