[backport 3.4] box: forbid concurrent invocation of box_raft_try_promote#12045
Merged
sergepetrenko merged 1 commit intorelease/3.4from Nov 24, 2025
Merged
[backport 3.4] box: forbid concurrent invocation of box_raft_try_promote#12045sergepetrenko merged 1 commit intorelease/3.4from
box_raft_try_promote#12045sergepetrenko merged 1 commit intorelease/3.4from
Conversation
Currently, we allow concurrent invocation of `box_raft_try_promote`, since
we either disable the `is_in_promote` guard in `box_promote` or omit it in
`box_cfg_xc`, while `box_raft_try_promote` yields to write the raft state.
This leads to a race over the `diag` of the fiber executing the
`box_raft_try_promote_f` trigger, and can lead to more bugs.
Let's forbid concurrent execution of `box_raft_try_promote` by enabling the
`is_in_promote` guard while `box_raft_try_promote` is called.
One potential caveat is the concurrent execution of `box_promote_qsync`
which is also guarded by the `is_in_promote`. However, it is executed in
the raft worker fiber and can be retried until `box_raft_try_promote`
execution finishes.
To be on the safer side, let's:
1. Call `raft_restore` before setting the fiber's `diag` to prevent any
potential tampering with it from `raft->on_update` triggers.
2. Set `is_box_configured` right before calling `box_raft_try_promote` to
maintain the invariant that it is always called by `box.cfg` first. Also
move `box_broadcast_ballot` for consistency.
The `raft_leader_promote` test from the gh-6033 test group should now test
that a concurrent promote fails rather than succeeds.
Closes #11703
Closes #11708
NO_DOC=<bugfix>
(cherry picked from commit b592845)
box_raft_try_promotebox_raft_try_promote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(This PR is a backport of #11882 to
release/3.4to a future3.4.2release.)This patch fixes two bugs related to concurrent invocation of
box_raft_try_promote.Closes #11703
Closes #11708