-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 8.0.13, 7.0.48
-
Component/s: Replication
-
None
-
Replication - Oplog and Recovery
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Versions: 7.0 and 8.0 confirmed. 9.0 and master: probably.
Problem
ReplicationCoordinatorImpl::signalDrainComplete runs on the OplogApplier thread. It takes AutoGetRstlForStepUpStepDown(kStepUp), and under the RSTL in X it does slow work:
- the term-bump doOptimizedReconfig, which persists the config and waits for a journal flush;
- onTransitionToPrimary: the session scan for prepared transactions, the no-op write, _dropAllTempCollections over every database, and the sharding hooks.
OplogApplier is a system client that the kill pass cannot interrupt. If a new term arrives during this window, the step-down from _stepDownFinish waits behind the step-up's X and fasserts.
Related but different: a step-up can also time out on the RSTL in signalDrainComplete itself, when other holders block it. That is a step-up blocked by other holders, not a step-down blocked by a step-up.
Evidence
- 7.0.48: two lock dumps with OplogApplier-0 holding the RSTL in X. In one, the term-bump reconfig alone took 5 to 7 s, and the X was held for more than 60 s. FTDC on both nodes shows empty ticket queues during the step-down.
- 8.0.13: two dumps with the same holder, one of them with a _dropAllTempCollections stack.
On master, signalApplierDrainComplete still takes AutoGetRstlForStepUpStepDown unconditionally, next to the intent registry's ReplicationStateTransitionGuard, so 9.0 and master may be affected too.
Proposed fix (options)
- Shorten the X section. Move _dropAllTempCollections and the session scan out from under the RSTL X; they do not need the node to be write-blocked. Avoid waiting for the journal flush under X.
- Let the step-up give way. If the term changes while signalDrainComplete holds X, abandon the step-up and release the RSTL instead of finishing it.