summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2022-09-16 16:12:29 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-16 19:40:17 +0000
commit7a8056a5319ea346ec4b91d598ed03d6cdf0947c (patch)
tree09601228cacbba71707241be0ce54d342ddfd9f8 /src/mongo/db
parentcae95e44291d09e1515bf85860d0ffe1632ce572 (diff)
downloadmongo-7a8056a5319ea346ec4b91d598ed03d6cdf0947c.tar.gz
SERVER-69777 Lock by dbName + UUID rather than namespace in `cleanUpRange`
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/migration_util.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp
index 66ce6733feb..55083911f44 100644
--- a/src/mongo/db/s/migration_util.cpp
+++ b/src/mongo/db/s/migration_util.cpp
@@ -414,21 +414,25 @@ ExecutorFuture<void> cleanUpRange(ServiceContext* serviceContext,
auto opCtx = uniqueOpCtx.get();
opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE();
- const NamespaceString& nss = deletionTask.getNss();
+ const auto dbName = deletionTask.getNss().dbName();
+ const auto collectionUuid = deletionTask.getCollectionUuid();
while (true) {
- {
+ boost::optional<NamespaceString> optNss;
+ try {
// Holding the locks while enqueueing the task protects against possible
// concurrent cleanups of the filtering metadata, that be serialized
- AutoGetCollection autoColl(opCtx, nss, MODE_IS);
- auto csr = CollectionShardingRuntime::get(opCtx, nss);
+ AutoGetCollection autoColl(
+ opCtx, NamespaceStringOrUUID{dbName, collectionUuid}, MODE_IS);
+ optNss.emplace(autoColl.getNss());
+ auto csr = CollectionShardingRuntime::get(opCtx, *optNss);
auto csrLock = CollectionShardingRuntime::CSRLock::lockShared(opCtx, csr);
auto optCollDescr = csr->getCurrentMetadataIfKnown();
if (optCollDescr) {
uassert(ErrorCodes::
RangeDeletionAbandonedBecauseCollectionWithUUIDDoesNotExist,
- str::stream() << "Filtering metadata for " << nss
+ str::stream() << "Filtering metadata for " << *optNss
<< (optCollDescr->isSharded()
? " has UUID that does not match UUID of "
"the deletion task"
@@ -447,9 +451,16 @@ ExecutorFuture<void> cleanUpRange(ServiceContext* serviceContext,
return csr->cleanUpRange(deletionTask.getRange(), whenToClean);
}
+ } catch (ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
+ uasserted(
+ ErrorCodes::RangeDeletionAbandonedBecauseCollectionWithUUIDDoesNotExist,
+ str::stream() << "Collection has been dropped since enqueuing this "
+ "range deletion task: "
+ << deletionTask.toBSON());
}
- refreshFilteringMetadataUntilSuccess(opCtx, nss);
+
+ refreshFilteringMetadataUntilSuccess(opCtx, *optNss);
}
})
.until([](Status status) mutable {