-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Sharding EMEA
-
ALL
Any code running `withTransaction` may end up with a deadlock if the given OperationContext has a SessionId and there is a deadlock during the transaction process.
The sequence of events leading to a deadlock is the following:
- (A): withTransaction thread
- (B): stepdown thread
1. (A) checks out a SessionId
2. (A) run withTransaction
3. (B) step-down thread starts and an interruption error is sent to all the threads.
4. (A) executes abortTransaction
4. (B) step-down thread acquires RSTL lock
5. (B) tries to checkout all sessions to kill them
6. (B) gets blocked when trying to checkout the session of thread A
7. (A) gets blocked trying to acquire RSTL lock to abort the transaction.
withTransaction is a method implemented as a utility for the ShardingCatalogManager when new transactions API didn't exist.
The new transaction API yields the session attached to the thread to avoid this scenario. So I suggest getting rid of withTransaction code and using the new transaction API instead. This is an example of implementation for the new transaction API
This issue was discovered when the sessionId was attached to the ConfigsvrCollMod request. The sessionId was finally removed to solve quickly the bug.
- duplicates
-
SERVER-77633 Calling withTransaction with a checked out session may end up in a deadlock (on stepdown)
- Closed