[SERVER-35217] killSessions command attempts to kill a transaction while holding SessionCatalog::_mutex, which leads to deadlock Created: 25/May/18 Updated: 29/Oct/23 Resolved: 08/Jun/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Concurrency, Replication |
| Affects Version/s: | 4.0.0-rc0 |
| Fix Version/s: | 4.0.0-rc5, 4.1.1 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Max Hirschhorn | Assignee: | Tess Avitabile (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | bkp, disabled-test, todo_in_code | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||
| Backport Requested: |
v4.0
|
||||||||||||||||||||||||||||||||
| Sprint: | Repl 2018-06-18 | ||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||
| Description |
|
Attempting to acquire a LockManager lock while holding a mutex is prone to deadlock. The SessionCatalog::scanSessions() function locks the session catalog and executes an arbitrary function on any matching sessions. For the "killSessions" command, this means that while holding the SessionCatalog::_mutex, it calls CursorManager::killAllCursorsForTransaction(), which for a find cursor attempts to acquire the collection lock in CursorManager::withCursorManager(). Since the killAllExpiredTransactions() function also calls SessionCatalog::scanSessions(), it isn't possible to reap expired transactions while the "killSessions" command is running. It similarly isn't possible to commit or abort a transaction while the "killSessions" command is running because SessionCatalog::checkOutSession() must acquire the SessionCatalog::_mutex. |
| Comments |
| Comment by Githook User [ 08/Jun/18 ] |
|
Author: {'username': 'tessavitabile', 'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com'}Message: (cherry picked from commit c0273c0a89e73ecfd7848fd4906a8e3c2d5886b9) |
| Comment by Githook User [ 08/Jun/18 ] |
|
Author: {'username': 'tessavitabile', 'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com'}Message: |
| Comment by Tess Avitabile (Inactive) [ 06/Jun/18 ] |
|
To address this issue, we will no longer kill associated client cursors when a transaction aborts or commits. That is, we will revert the work done in The decision was made with david.storch, shane.harvey, and jesse. |