[SERVER-57360] Log additional debug info for the "invariant (_requests.empty());" in ~LockerImpl Created: 02/Jun/21  Updated: 29/Oct/23  Resolved: 21/Jun/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.2.16, 5.0.3, 4.4.9, 5.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: Dianna Hohensee (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-55379 Invariant failure _requests.empty() a... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.0, v4.4, v4.2
Sprint: Execution Team 2021-06-14, Execution Team 2021-06-28
Participants:

 Description   

Somehow, the TransactionCoordinator, which appears to only take a mutex(es) in its own implementation, managed to invariant in ~LockerImpl after failing to acquire the global lock for a document write sub-operation via the DBDirectClient.

It's unclear to me what could have gone wrong. The TransactionParticipant is the only component in the codebase using Locker instances outside of RAII types, but the TransactionCoordinator isn't involved with the TransactionParticipant at all as far as I can tell. We could add some logging information to the invariant failure. It isn't clear what information would be helpful, so basically whatever we can. ~LockerImpl checks that the lock requests are empty, which is a map of ResourceId to LockRequest -- we could log some of this information.

The invariant failure was seen in the v4.2 branch.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 20/Aug/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-57360 Log additional debug info for invariant(_requests.empty()) in ~LockerImpl

(cherry picked from commit a260a07648a984acaa54ab8cb1d18b37434d1b97)
Branch: v4.2
https://github.com/mongodb/mongo/commit/18315d2e163ce47d0d7ca7503961c4566e04d70a

Comment by Githook User [ 10/Aug/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-57360 Log additional debug info for invariant(_requests.empty()) in ~LockerImpl

(cherry picked from commit a260a07648a984acaa54ab8cb1d18b37434d1b97)
Branch: v4.4
https://github.com/mongodb/mongo/commit/8a494bb590772e9349e37c41014f3fcf99f9deb1

Comment by Githook User [ 04/Aug/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-57360 Log additional debug info for invariant(_requests.empty()) in ~LockerImpl

(cherry picked from commit a260a07648a984acaa54ab8cb1d18b37434d1b97)
Branch: v5.0
https://github.com/mongodb/mongo/commit/ecd1c4cdda6eda0b36e2820da2635fd985530f63

Comment by Githook User [ 21/Jun/21 ]

Author:

{'name': 'Dianna Hohensee', 'email': 'dianna.hohensee@mongodb.com', 'username': 'DiannaHohensee'}

Message: SERVER-57360 Log additional debug info for invariant(_requests.empty()) in ~LockerImpl
Branch: master
https://github.com/mongodb/mongo/commit/a260a07648a984acaa54ab8cb1d18b37434d1b97

Comment by Dianna Hohensee (Inactive) [ 02/Jun/21 ]

Something like this as a starting point, maybe??

diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index b684416b44..c8c0b322b4 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -286,6 +286,12 @@ LockerImpl::~LockerImpl() {
     // to delete with unaccounted locks anyways.
     invariant(!inAWriteUnitOfWork());
     invariant(_numResourcesToUnlockAtEndUnitOfWork == 0);
+    std::string lockRequestsStr = "";
+    for (auto it = _requests.begin(); it != _requests.end(); ++it) {
+        // LockRequest* lockRequest = it.objAddr();
+        lockRequestsStr += "{ Resource ID: " + ResourceTypeNames[it.key()];
+        // lockRequestsStr += ", Lock Request: {Statue: " + + "}}";
+    }
     invariant(_requests.empty());
     invariant(_modeForTicket == MODE_NONE);

Generated at Thu Feb 08 05:41:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.