fix(miner): fix timer handshake deadlock in worker.update() - #2493
Open
gzliudan wants to merge 1 commit into
Open
fix(miner): fix timer handshake deadlock in worker.update()#2493gzliudan wants to merge 1 commit into
worker.update()#2493gzliudan wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
gzliudan
requested review from
AnilChinchawale,
anunay-xin,
benjamin202410,
liam-lai and
wanwiset25
July 27, 2026 23:51
benjamin202410
approved these changes
Jul 28, 2026
worker.update()
gzliudan
added a commit
to gzliudan/XDPoSChain
that referenced
this pull request
Jul 29, 2026
…g#2493 The mining timer was owned by a dedicated goroutine that exchanged notifications with the update loop over two buffered channels: the loop sent the next duration on resetCh and the goroutine reported expiries on c. Both channels have a capacity of one, so once both buffers were full the two goroutines blocked on each other forever. When that happened the worker stopped draining chainHeadCh and chainSideCh. Chain events are posted synchronously, so block insertion blocked in event.Feed.Send, the downloader never finished its sync round, and the node stopped importing blocks entirely. Own the timer from the update loop itself, which removes the handshake and therefore the cycle.
gzliudan
force-pushed
the
fix-miner-worker-deadlock
branch
from
July 29, 2026 02:59
314a1bc to
2d4cd1a
Compare
The mining timer was owned by a dedicated goroutine that exchanged notifications with the update loop over two buffered channels: the loop sent the next duration on resetCh and the goroutine reported expiries on c. Both channels have a capacity of one, so once both buffers were full the two goroutines blocked on each other forever. When that happened the worker stopped draining chainHeadCh and chainSideCh. Chain events are posted synchronously, so block insertion blocked in event.Feed.Send, the downloader never finished its sync round, and the node stopped importing blocks entirely. Own the timer from the update loop itself, which removes the handshake and therefore the cycle.
gzliudan
force-pushed
the
fix-miner-worker-deadlock
branch
from
July 29, 2026 02:59
2d4cd1a to
a56164d
Compare
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.
Proposed changes
The mining timer was owned by a dedicated goroutine that exchanged notifications with the update loop over two buffered channels: the loop sent the next duration on resetCh and the goroutine reported expiries on c. Both channels have a capacity of one, so once both buffers were full the two goroutines blocked on each other forever.
When that happened the worker stopped draining chainHeadCh and chainSideCh. Chain events are posted synchronously, so block insertion blocked in event.Feed.Send, the downloader never finished its sync round, and the node stopped importing blocks entirely.
Own the timer from the update loop itself, which removes the handshake and therefore the cycle.
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that