diff options
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r-- | src/mongo/db/s/config/sharding_catalog_manager.cpp | 21 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_mongod_test_fixture.cpp | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/mongo/db/s/config/sharding_catalog_manager.cpp b/src/mongo/db/s/config/sharding_catalog_manager.cpp index cf1c9466748..813c6f3d0d3 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager.cpp @@ -280,6 +280,23 @@ Status createUuidIndexesForConfigChunks(OperationContext* opCtx) { return Status::OK(); } +/** + * This step runs on FCV switch between 4.4 <-> 5.0, right after the shards have been told to enter + * Phase 1 and after all the local chunks' format has been changed to contain both UUID and + * Namespace. + * + * If isOnUpgrade is true, it will remove any config.chunks entries, which do not have UUID and if + * it is false, it will remove those which do not have Namespace. + */ +void removeIncompleteChunks(OperationContext* opCtx, bool isOnUpgrade) { + const auto catalogClient = Grid::get(opCtx)->catalogClient(); + + auto query = isOnUpgrade ? BSON(ChunkType::collectionUUID << BSON("$exists" << false)) + : BSON(ChunkType::ns << BSON("$exists" << false)); + uassertStatusOK(catalogClient->removeConfigDocuments( + opCtx, ChunkType::ConfigNS, query, ShardingCatalogClient::kLocalWriteConcern)); +} + } // namespace void ShardingCatalogManager::create(ServiceContext* serviceContext, @@ -795,6 +812,8 @@ void ShardingCatalogManager::_upgradeCollectionsAndChunksEntriesTo50Phase1( true /* multi */); } + removeIncompleteChunks(opCtx, true /* isOnUpgrade */); + // Create uuid_* indexes for config.chunks uassertStatusOK(createUuidIndexesForConfigChunks(opCtx)); @@ -938,6 +957,8 @@ void ShardingCatalogManager::_downgradeCollectionsAndChunksEntriesToPre50Phase1( true /* multi */); } + removeIncompleteChunks(opCtx, false /* isOnUpgrade */); + // Create ns_* indexes for config.chunks uassertStatusOK(createNsIndexesForConfigChunks(opCtx)); diff --git a/src/mongo/db/s/sharding_mongod_test_fixture.cpp b/src/mongo/db/s/sharding_mongod_test_fixture.cpp index e65baf54fb6..3760b7e0661 100644 --- a/src/mongo/db/s/sharding_mongod_test_fixture.cpp +++ b/src/mongo/db/s/sharding_mongod_test_fixture.cpp @@ -51,7 +51,6 @@ #include "mongo/db/repl/replication_process.h" #include "mongo/db/repl/replication_recovery_mock.h" #include "mongo/db/repl/storage_interface_mock.h" -#include "mongo/db/s/collection_sharding_state_factory_shard.h" #include "mongo/db/s/config_server_op_observer.h" #include "mongo/db/s/op_observer_sharding_impl.h" #include "mongo/db/s/shard_local.h" |