summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Polato <paolo.polato@mongodb.com>2021-06-02 10:28:32 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-02 11:00:48 +0000
commit8dc7a2363f71c00f79354ca961197692201a5100 (patch)
tree4d7f3347f56515f49a57624113474393c1f60986
parent469ba14218e31ce9756888593d88fada001bf6f0 (diff)
downloadmongo-8dc7a2363f71c00f79354ca961197692201a5100.tar.gz
SERVER-56786 Ensure that the query on config.collections succeeds
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp10
1 files 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<BSONObj> 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<BSONObj> 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 {