diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2022-09-07 21:47:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-07 22:42:44 +0000 |
commit | fbd396a5acef49a31a235cdb2ce1e1f76c04a70a (patch) | |
tree | 5275347e825bcff971f44d5d31b966e90d04553e | |
parent | 1edab98fff4a8b77412251b35fe5148afd0b6793 (diff) | |
download | mongo-fbd396a5acef49a31a235cdb2ce1e1f76c04a70a.tar.gz |
SERVER-69406 Place an InterruptibleLockGuard in the find cmd path because it runs without a ClientCursorPin
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 8 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 147ce04d933..bf40647a9cf 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -295,6 +295,15 @@ public: AutoGetCollectionViewMode::kViewsPermitted); const auto nss = ctx->getNss(); + // Going forward this operation must never ignore interrupt signals while waiting for + // lock acquisition. This InterruptibleLockGuard will ensure that waiting for lock + // re-acquisition after yielding will not ignore interrupt signals. This is necessary to + // avoid deadlocking with replication rollback, which at the storage layer waits for all + // cursors to be closed under the global MODE_X lock, after having sent interrupt + // signals to read operations. This operation must never hold open storage cursors while + // ignoring interrupt. + InterruptibleLockGuard interruptibleLockAcquisition(opCtx->lockState()); + // Parse the command BSON to a FindCommandRequest. auto findCommand = parseCmdObjectToFindCommandRequest(opCtx, nss, _request.body); @@ -471,6 +480,15 @@ public: AutoGetCollectionViewMode::kViewsPermitted); const auto& nss = ctx->getNss(); + // Going forward this operation must never ignore interrupt signals while waiting for + // lock acquisition. This InterruptibleLockGuard will ensure that waiting for lock + // re-acquisition after yielding will not ignore interrupt signals. This is necessary to + // avoid deadlocking with replication rollback, which at the storage layer waits for all + // cursors to be closed under the global MODE_X lock, after having sent interrupt + // signals to read operations. This operation must never hold open storage cursors while + // ignoring interrupt. + InterruptibleLockGuard interruptibleLockAcquisition(opCtx->lockState()); + uassert(ErrorCodes::NamespaceNotFound, str::stream() << "UUID " << findCommand->getNamespaceOrUUID().uuid().value() << " specified in query request not found", diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 28909dd442b..e61f799620c 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -705,6 +705,14 @@ Status runAggregate(OperationContext* opCtx, boost::optional<AutoGetCollectionForReadCommandMaybeLockFree> ctx; MultipleCollectionAccessor collections; + // Going forward this operation must never ignore interrupt signals while waiting for lock + // acquisition. This InterruptibleLockGuard will ensure that waiting for lock re-acquisition + // after yielding will not ignore interrupt signals. This is necessary to avoid deadlocking with + // replication rollback, which at the storage layer waits for all cursors to be closed under the + // global MODE_X lock, after having sent interrupt signals to read operations. This operation + // must never hold open storage cursors while ignoring interrupt. + InterruptibleLockGuard interruptibleLockAcquisition(opCtx->lockState()); + auto initContext = [&](AutoGetCollectionViewMode m) -> void { ctx.emplace(opCtx, nss, |