[SERVER-33959] CursorManager attempts to dispose of aggregation cursors while holding partitioned lock, which leads to deadlock Created: 17/Mar/18  Updated: 29/Oct/23  Resolved: 15/May/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: 3.6.0, 3.7.1
Fix Version/s: 3.6.6, 4.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Charlie Swanson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-22541 Aggregation plan executors should be ... Closed
is related to SERVER-69143 CursorManager no longer needs to hand... Open
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: Query 2018-05-07, Query 2018-05-21
Participants:
Linked BF Score: 19

 Description   

Attempting to acquire a LockManager lock while holding a mutex is prone to deadlock. The CursorManager::killCursor() function locks the partition of CursorManager::_cursorMap corresponding to the specified cursor id. While holding the mutex, it calls ClientCursor::dispose(), which for an aggregation cursor attempts to acquire the collection lock in DocumentSourceCursor::cleanupExecutor() as part of DocumentSourceCursor::doDispose(). The "listCollections" and "listIndexes" commands hold the collection lock when attempting to call CursorManager::registerCursor(), forming the other edge of the deadlock cycle.



 Comments   
Comment by Githook User [ 14/Jun/18 ]

Author:

{'username': 'cswanson310', 'name': 'Charlie Swanson', 'email': 'charlie.swanson@mongodb.com'}

Message: SERVER-33959 Avoid deadlock during global cursor registration

(cherry picked from commit fa9278c892a6833694983191a5726b20f6a187a0)
Branch: v3.6
https://github.com/mongodb/mongo/commit/d27aa4e8ebb950cce072f188d732958aec4bd083

Comment by Githook User [ 15/May/18 ]

Author:

{'email': 'charlie.swanson@mongodb.com', 'username': 'cswanson310', 'name': 'Charlie Swanson'}

Message: SERVER-33959 Avoid deadlock during global cursor registration
Branch: master
https://github.com/mongodb/mongo/commit/fa9278c892a6833694983191a5726b20f6a187a0

Generated at Thu Feb 08 04:35:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.