summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/s/drop_collection_coordinator.cpp13
-rw-r--r--src/mongo/db/s/range_deleter_service.cpp3
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) {