miner, consensus/clique: avoid memory leak during block stasis#23861
Merged
Conversation
rjl493456442
approved these changes
Nov 5, 2021
Contributor
Author
sidhujag
pushed a commit
to syscoin/go-ethereum
that referenced
this pull request
Nov 7, 2021
…eum#23861) This PR fixes a problem which arises on clique networks when there is a network stall. Previously, the worker packages were tracked, even if the sealing engine decided not to seal the block (due to clique rules about recent signing). These tracked-but-not-sealed blocks kept building up in memory. This PR changes the situation so the sealing engine instead returns an error, and the worker can thus un-track the package.
This was referenced Sep 23, 2022
yongjun925
pushed a commit
to DODOEX/go-ethereum
that referenced
this pull request
Dec 3, 2022
…eum#23861) This PR fixes a problem which arises on clique networks when there is a network stall. Previously, the worker packages were tracked, even if the sealing engine decided not to seal the block (due to clique rules about recent signing). These tracked-but-not-sealed blocks kept building up in memory. This PR changes the situation so the sealing engine instead returns an error, and the worker can thus un-track the package.
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.

When a clique network is not progressing, we see a memory leak:
This is pretty bad, because whenever one signer falls off, then the rest of them eventually will crash too -- so one failing sealer will wreak havoc, causing other sealers to crash and making it very difficult to get the network live again.
Every
3seconds (miner.recommitinterval) we shove a new task to be handed, where we e.g. deep-copy the receipts and other stuff and send it over a channelw.taskCh <- &task{receipts: receipts, state: s, block: block, createdAt: time.Now()}:That get's shoved into a map
So every 3 seconds (miner recommit), we leak a block into memory, basically.
The routine that would have cleaned that up :
Won't clean close to head, and besides, it's not executed unless blocks progress.
When we hit this case:
Then
Signed recently, must wait for othersmeans that we did not actually start a sealing-task at all, so there's no point tracking the work package. This PR changes the behavior so that