Currently runCmdOnPrimaryAndAwaitResponse() takes RSTL lock in IX mode and performs DBDirectClient command using AlternativeClientRegion. If the DBDirectClient command takes RSTL lock in the AlternativeClientRegion's opCtx, then it can lead to deadlock involving the stepdown thread and the thread that calls runCmdOnPrimaryAndAwaitResponse().
The reason for the deadlock is that, the stepdown thread can't acquire RSTL lock as the caller's original opCtx (including locks) has been stashed and replaced with a new opCtx by runCmdOnPrimaryAndAwaitResponse() using AlternativeClientRegion class. So, no way stepdown can interrupt and make the original opCtx to release the locks. As a result, StepDown thread gets blocked behind runCmdOnPrimaryAndAwaitResponse() RSTL lock due to lock conflict . DBDirectClient command gets blocked behind stepdown as stepdown has enqueued the RSTL lock in X mode. And, runCmdOnPrimaryAndAwaitResponse() will be waiting for the DBDirectClient command's response.
- is duplicated by
-
SERVER-46663 runCmdOnPrimaryAndAwaitResponse() should not run DBDirect client command with the rstl lock held.
- Closed
- is related to
-
SERVER-46704 Two phase index build can violate locking ordering and can lead to deadlocks.
- Closed