Repository navigation
fix(consensus): release cs.mtx before sending to statsMsgQueue (backport #5813) - #5998
Merged
Merged
Conversation
## Problem `handleMsg` sent to `cs.statsMsgQueue` while holding `cs.mtx`. If the buffer fills, the send blocks indefinitely — stalling the entire consensus state machine. ## Fix Hoist the `statsMsgQueue` send outside the `switch`, release `cs.mtx` before the send and re-acquire after. This also removes the duplicated `added` checks inside each `case` block, replacing them with a single check at the bottom. ## Testing - `TestHandleMsgReleasesLockBeforeStatsMsgQueueSend`: verifies `GetRoundState()` is not blocked while `handleMsg` is blocked on the send. --- #### PR checklist - [x] Tests written/updated - [x] Changelog entry added in `CHANGELOG.md` - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Dmitry S <[email protected]> (cherry picked from commit bd8bb65) # Conflicts: # CHANGELOG.md
Contributor
Author
|
Cherry-pick of bd8bb65 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Contributor
|
PR author is not in the allowed authors list. |
swift1337
approved these changes
Jul 27, 2026
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
4 tasks
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.
Problem
handleMsgsent tocs.statsMsgQueuewhile holdingcs.mtx. If the buffer fills, the send blocks indefinitely — stalling the entire consensus state machine.Fix
Hoist the
statsMsgQueuesend outside theswitch, releasecs.mtxbefore the send and re-acquire after.This also removes the duplicated
addedchecks inside eachcaseblock, replacing them with a single check at the bottom.Testing
TestHandleMsgReleasesLockBeforeStatsMsgQueueSend: verifiesGetRoundState()is not blocked whilehandleMsgis blocked on the send.PR checklist
CHANGELOG.mddocs/orspec/) and code commentsThis is an automatic backport of pull request fix(consensus): release cs.mtx before sending to statsMsgQueue #5813 done by Mergify.