diff options
author | Silvia Surroca <silvia.surroca@mongodb.com> | 2022-09-27 13:45:23 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-27 14:17:30 +0000 |
commit | cb8b9029c089316a198b5f98a74ae21fc1f18299 (patch) | |
tree | 6b1f87171bb685589c8d180985e3c30765660a50 | |
parent | b81eb4d060bb296628338c6f6a3a752cdf47cdfa (diff) | |
download | mongo-cb8b9029c089316a198b5f98a74ae21fc1f18299.tar.gz |
SERVER-65016 Remove range deletions as part of `dropCollection`
-rw-r--r-- | src/mongo/db/s/drop_collection_coordinator.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/s/range_deleter_service.cpp | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/db/s/drop_collection_coordinator.cpp b/src/mongo/db/s/drop_collection_coordinator.cpp index 7061a240378..3510faf2e1d 100644 --- a/src/mongo/db/s/drop_collection_coordinator.cpp +++ b/src/mongo/db/s/drop_collection_coordinator.cpp @@ -68,11 +68,9 @@ DropReply DropCollectionCoordinator::dropCollectionLocally(OperationContext* opC csr->clearFilteringMetadataForDroppedCollection(opCtx); } - DropReply result; - uassertStatusOK(dropCollection( - opCtx, nss, &result, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); - - // Remove all range deletion task documents present on disk for the dropped collection + // Remove all range deletion task documents present on disk for the collection to drop. This is + // a best-effort tentative considering that migrations are not blocked, hence some new document + // may be inserted before actually dropping the collection. if (collectionUUID) { // The multi-document remove command cannot be run in transactions, so run it using // an alternative client. @@ -97,6 +95,11 @@ DropReply DropCollectionCoordinator::dropCollectionLocally(OperationContext* opC } } + DropReply result; + uassertStatusOK(dropCollection( + opCtx, nss, &result, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); + + // Force the refresh of the catalog cache to purge outdated information const auto catalog = Grid::get(opCtx)->catalogCache(); uassertStatusOK(catalog->getCollectionRoutingInfoWithRefresh(opCtx, nss)); diff --git a/src/mongo/db/s/range_deleter_service.cpp b/src/mongo/db/s/range_deleter_service.cpp index d27c71f3932..954fc10395c 100644 --- a/src/mongo/db/s/range_deleter_service.cpp +++ b/src/mongo/db/s/range_deleter_service.cpp @@ -487,6 +487,9 @@ SharedSemiFuture<void> RangeDeleterService::registerTask( void RangeDeleterService::deregisterTask(const UUID& collUUID, const ChunkRange& range) { auto lock = _acquireMutexFailIfServiceNotUp(); _rangeDeletionTasks[collUUID].erase(std::make_shared<ChunkRange>(range)); + if (_rangeDeletionTasks[collUUID].size() == 0) { + _rangeDeletionTasks.erase(collUUID); + } } int RangeDeleterService::getNumRangeDeletionTasksForCollection(const UUID& collectionUUID) { |