summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-01-14 18:35:40 +0000
committerevergreen <evergreen@mongodb.com>2020-01-14 18:35:40 +0000
commitc0c5a486846f9d0b4a0ee6db6f58df6a127e6da7 (patch)
tree89590b4c127f4ac0d8e2f06473fb4c984d31a992
parenta5da3c438438194bab72bd6d98118fa6f7e02699 (diff)
downloadmongo-c0c5a486846f9d0b4a0ee6db6f58df6a127e6da7.tar.gz
SERVER-37406 Save logical session id in the locker when stashing the transaction
(cherry picked from commit b1830f1ad949059fd7d70cc9490e0216fd30b438)
-rw-r--r--src/mongo/db/concurrency/lock_manager.cpp6
-rw-r--r--src/mongo/db/concurrency/locker.h9
-rw-r--r--src/mongo/db/session.cpp3
3 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/db/concurrency/lock_manager.cpp b/src/mongo/db/concurrency/lock_manager.cpp
index 869057aaa23..58321d1e50b 100644
--- a/src/mongo/db/concurrency/lock_manager.cpp
+++ b/src/mongo/db/concurrency/lock_manager.cpp
@@ -916,7 +916,8 @@ void LockManager::_dumpBucket(const LockBucket* bucket) const {
<< "Thread = " << threadId.str() << "; "
<< "ConvertMode = " << modeName(iter->convertMode) << "; "
<< "EnqueueAtFront = " << iter->enqueueAtFront << "; "
- << "CompatibleFirst = " << iter->compatibleFirst << "; " << '\n';
+ << "CompatibleFirst = " << iter->compatibleFirst << "; "
+ << "DebugInfo = " << iter->locker->getDebugInfo() << '\n';
}
sb << "PENDING:\n";
@@ -930,7 +931,8 @@ void LockManager::_dumpBucket(const LockBucket* bucket) const {
<< "Thread = " << threadId.str() << "; "
<< "ConvertMode = " << modeName(iter->convertMode) << "; "
<< "EnqueueAtFront = " << iter->enqueueAtFront << "; "
- << "CompatibleFirst = " << iter->compatibleFirst << "; " << '\n';
+ << "CompatibleFirst = " << iter->compatibleFirst << "; "
+ << "DebugInfo = " << iter->locker->getDebugInfo() << '\n';
}
sb << "-----------------------------------------------------------\n";
diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h
index 9bd9864794a..5d120c0d0b0 100644
--- a/src/mongo/db/concurrency/locker.h
+++ b/src/mongo/db/concurrency/locker.h
@@ -452,6 +452,14 @@ public:
return _numResourcesToUnlockAtEndUnitOfWork;
}
+ std::string getDebugInfo() const {
+ return _debugInfo;
+ }
+
+ void setDebugInfo(const std::string& info) {
+ _debugInfo = info;
+ }
+
protected:
Locker() {}
@@ -472,6 +480,7 @@ protected:
private:
bool _shouldConflictWithSecondaryBatchApplication = true;
bool _shouldAcquireTicket = true;
+ std::string _debugInfo; // Extra info about this locker for debugging purpose
};
/**
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp
index 7149b4fd085..f58071ac843 100644
--- a/src/mongo/db/session.cpp
+++ b/src/mongo/db/session.cpp
@@ -630,6 +630,9 @@ Session::TxnResources::TxnResources(OperationContext* opCtx, bool keepTicket) {
_locker->releaseTicket();
}
_locker->unsetThreadId();
+ if (opCtx->getLogicalSessionId()) {
+ _locker->setDebugInfo("lsid: " + opCtx->getLogicalSessionId()->toBSON().toString());
+ }
// This thread must still respect the transaction lock timeout, since it can prevent the
// transaction from making progress.