Fix retention hanging forever when the permanent store is disabled - #59
Open
damilolaedwards wants to merge 1 commit into
Open
Conversation
purgeOldBeaconBlocks queued every aged out block with the permanent store and then waited on a channel that the permanent store only closed once the block was actually handed off for processing. When the permanent store is disabled, which is the default, or stopped, or its queue is full, QueueBlock returned without ever touching that channel, so the wait never completed. Since all retention purges run one after another on a single goroutine, this stalled cleanup for every data type the first time a beacon block aged out, silently and permanently. QueueBlock now closes the channel on every path, not only the one where a block is actually queued. Retention's wait also now selects on context cancellation as a second line of defense, so a purge in progress during shutdown does not block indefinitely either.
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.
Summary
purgeOldBeaconBlocksqueues every aged out block with the permanent store and then waits on a channel that the permanent store only closes once the block is actually handed off for processing. When the permanent store is disabled, which is the default, or stopped, or its queue is full,QueueBlockreturned without ever touching that channel, so the wait never completed.Since all six retention purges run one after another on a single goroutine, this stalls cleanup for every data type the moment the first beacon block ages out, silently and permanently. No attacker or unusual configuration is needed, just the documented default.
QueueBlocknow closes the channel on every path, not only the one where a block is actually queued. Retention's wait also now selects on context cancellation as a second line of defense, so a purge in progress during shutdown cannot block indefinitely either.Changes
pkg/server/service/indexer/permanent_store.go:QueueBlockclosesProcessedChanon every early return path via a small shared helper, also used byprocessBlock's existing closepkg/server/service/indexer/retention.go: the wait onProcessedChannow also selects onctx.Done()pkg/server/service/indexer/retention_test.go: two new tests, no prior test coverage existed for retention at allTest plan
go build ./...andgo vet ./...pass