- 
    Type:
Improvement
 - 
    Resolution: Unresolved
 - 
    Priority:
Major - P3
 - 
    None
 - 
    Affects Version/s: None
 - 
    Component/s: None
 - 
    None
 
- 
        Catalog and Routing
 - 
        Execution Team 2022-12-12, Execution Team 2022-12-26, Execution Team 2023-01-09
 - 
        None
 
- 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 
The deadlocks described in SERVER-71191 and SERVER-44722 are caused because the following conditions are true, in general
- An operation is unkillable by stepdown
 - While holding the RSTL in IX mode, an operation takes an X collection lock. If there are any prepared transactions, this blocks.
 - The stepdown thread tries to acquire the X lock, but blocks because of a conflict
 
In this situation, the operation that isn't interrupted by stepdown does not make progress. We should add an assertion to our lock helpers that prevent unkillable operations from taking X locks while also holding the RSTL.
- is related to
 - 
                    
SERVER-78662 Deadlock with index build, step down, prepared transaction, and MODE_IS coll lock
-         
 - Closed
 
 -         
 - 
                    
SERVER-73036 Investigate potential deadlock with index builds
-         
 - Closed
 
 -         
 - 
                    
SERVER-72898 Investigate if updateShardIdentityConfigString can use MODE_IX lock
-         
 - Closed
 
 -         
 - 
                    
SERVER-72897 Investigate unorthodox locking in ReplicationCoordinatorExternalState
-         
 - Closed
 
 -         
 
- related to
 - 
                    
SERVER-44722 3 way deadlock can happen between hybrid index build, prepared transactions and stepdown thread on primary that runs index build via coordinator.
-         
 - Closed
 
 -         
 - 
                    
SERVER-71191 Deadlock between index build setup, prepared transaction, and stepdown
-         
 - Closed
 
 -         
 - 
                    
SERVER-75288 Investigate whether the stepdown killop thread should kill operations that hold the RSTL
-         
 - Open
 
 -