292: Backfill gaps in the recent past on startup when tracking head. #395
Merged
telackey
merged 11 commits from 2023-06-24 04:04:57 +00:00
telackey/292 into v1.11.6-statediff-v5
Dismiss Review
Are you sure you want to dismiss this review?
Labels
Clear labels
bug
critical
duplicate
enhancement
epic
help wanted
in progress
invalid
low priority
question
rebase
v1
v5
wontfix
Copied from Github
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
An issue or PR manually copied from GitHub.
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cerc-io/go-ethereum#395
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This adds a new
Backfillcheck which is run at startup, which attempts to recover from two sorts of gaps which can occur when tracking head:A contiguous gap from the last statediff position to the current head position. Something like this can happen if statediffs are in-flight when geth is terminated, or if there is an error which prevents writing statediffs but not syncing the chain (eg, the DB goes down). On startup then, we might notice that the current chain block is 2500, but the current statediff position is only 2498. The next ChainEvent we can expect to see will be at 2501, so we want to trigger statediffing of 2498, 2499, and 2500.
Discontiguous gaps in the recent past. These can happen from temporary errors (eg, a momentary disruption in DB connectivity) or if the process is terminated with in-flight statediffs that completed out-of-order. Eg, block 2500 got written but 2498 and 2499 were still in-flight, leaving a sequence like: 2496, 2497, 2500, ... In this scenario, the statediff and chain positions are in sync, but we still need to plug the hole behind the current position.
I set default limits of 7200 blocks (~1 day) in both cases. If the statediff position is more than 7200 blocks behind head, it will not attempt to backfill and will instead log an error. When looking for gaps, it will look no further back than 7200 blocks from the current statediff position. Both are configurable.
To handle more extreme situations, we also have
chain-chunker fillgapwhich can detect and fill gaps across an arbitrary range.Tests:
aa53b8abcbLGTM! One non-nitpick comment but it doesn't need to block this and we already discussed the testing situation 👍
Tests added here:
aa53b8abcb