diff options
Diffstat (limited to 'src/mongo/db/s/range_deleter_service.cpp')
-rw-r--r-- | src/mongo/db/s/range_deleter_service.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mongo/db/s/range_deleter_service.cpp b/src/mongo/db/s/range_deleter_service.cpp index ee5ff61f608..e0027e09bfe 100644 --- a/src/mongo/db/s/range_deleter_service.cpp +++ b/src/mongo/db/s/range_deleter_service.cpp @@ -320,7 +320,8 @@ SharedSemiFuture<void> RangeDeleterService::registerTask( .then([this, dbName = rdt.getNss().dbName(), collectionUuid = rdt.getCollectionUuid(), - range = rdt.getRange()]() { + range = rdt.getRange(), + optKeyPattern = rdt.getKeyPattern()]() { return withTemporaryOperationContext( [&](OperationContext* opCtx) { // A task is considered completed when all the following conditions are met: @@ -344,10 +345,16 @@ SharedSemiFuture<void> RangeDeleterService::registerTask( "range"_attr = redact(range.toString())); auto shardKeyPattern = - getShardKeyPattern(opCtx, dbName, collectionUuid); - - uassertStatusOK(deleteRangeInBatches( - opCtx, dbName, collectionUuid, shardKeyPattern, range)); + (optKeyPattern ? *optKeyPattern + : getShardKeyPattern( + opCtx, dbName, collectionUuid)); + + uassertStatusOK( + deleteRangeInBatches(opCtx, + dbName, + collectionUuid, + shardKeyPattern.toBSON(), + range)); orphansRemovalCompleted = true; } catch (ExceptionFor<ErrorCodes::NamespaceNotFound>&) { // No orphaned documents to remove from a dropped collection |