From 8dc7a2363f71c00f79354ca961197692201a5100 Mon Sep 17 00:00:00 2001 From: Paolo Polato Date: Wed, 2 Jun 2021 10:28:32 +0000 Subject: SERVER-56786 Ensure that the query on config.collections succeeds --- .../db/s/config/sharding_catalog_manager_chunk_operations.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp index 9d8cf39e48e..cb7976b85c7 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp @@ -892,9 +892,7 @@ StatusWith ShardingCatalogManager::commitChunksMerge( << "mergeChunk cannot merge chunks."); } - // 2. Retrieve the list of chunks belonging to the requested shard + key range; - // The query over config.collections is guaranteed to succeed, - // since it has been already issued & checked by getCollectionVersion() + // 2. Retrieve the list of chunks belonging to the requested shard + key range. auto findCollResponse = uassertStatusOK( configShard->exhaustiveFindOnConfig(opCtx, ReadPreferenceSetting{ReadPreference::PrimaryOnly}, @@ -903,6 +901,12 @@ StatusWith ShardingCatalogManager::commitChunksMerge( BSON(CollectionType::kNssFieldName << nss.ns()), {}, 1)); + + if (findCollResponse.docs.empty()) { + return {ErrorCodes::Error(5678601), + str::stream() << "Collection '" << nss.ns() << "' no longer either exists"}; + } + const CollectionType coll(findCollResponse.docs[0]); if (coll.getUuid() != requestCollectionUUID) { return { -- cgit v1.2.1