From e3a69aae7d5a45a61ea7796efdeb77b4392597e4 Mon Sep 17 00:00:00 2001 From: jinichu Date: Wed, 8 Aug 2018 09:17:10 -0400 Subject: SERVER-36007 Fixed self-deadlock caused by checking out an already checked out session in SessionCatalog --- src/mongo/db/session_catalog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp index 614e2ed8144..24fcea6b37e 100644 --- a/src/mongo/db/session_catalog.cpp +++ b/src/mongo/db/session_catalog.cpp @@ -258,10 +258,11 @@ OperationContextSession::OperationContextSession(OperationContext* opCtx, auto& checkedOutSession = operationSessionDecoration(opCtx); if (!checkedOutSession) { auto sessionTransactionTable = SessionCatalog::get(opCtx); + auto scopedCheckedOutSession = sessionTransactionTable->checkOutSession(opCtx); // We acquire a Client lock here to guard the construction of this session so that // references to this session are safe to use while the lock is held. stdx::lock_guard lk(*opCtx->getClient()); - checkedOutSession.emplace(sessionTransactionTable->checkOutSession(opCtx)); + checkedOutSession.emplace(std::move(scopedCheckedOutSession)); } else { // The only reason to be trying to check out a session when you already have a session // checked out is if you're in DBDirectClient. -- cgit v1.2.1