Skip to content

fix(blocksync): fix deadlock in AddBlock caused by holding pool.mtx during sendError - #2

Closed
songgaoye wants to merge 1 commit into
mainfrom
song/fix_BlockPool_AddBlock
Closed

fix(blocksync): fix deadlock in AddBlock caused by holding pool.mtx during sendError#2
songgaoye wants to merge 1 commit into
mainfrom
song/fix_BlockPool_AddBlock

Conversation

@songgaoye

@songgaoye songgaoye commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Fix CI failure at: https://github.com/cometbft/cometbft/actions/runs/27214146296/job/80350996164

  • AddBlock held pool.mtx via a deferred Unlock while calling sendError on an unbuffered channel. Any concurrent caller that also needed pool.mtx would deadlock until the channel was drained.
  • Fix by collecting the error in sendErr and dispatching it inside the defer after the mutex is released.
  • Adds a regression test that confirms pool.Height() (which acquires pool.mtx) can proceed while AddBlock is blocked in sendError.

PR checklist

  • Tests written/updated
  • Changelog entry added in CHANGELOG.md
  • Updated relevant documentation (docs/ or spec/) and code comments

@songgaoye songgaoye closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant