fix(worker): don't queue catchup from genesis on cold start#105
Open
vietddude wants to merge 1 commit into
Open
fix(worker): don't queue catchup from genesis on cold start#105vietddude wants to merge 1 commit into
vietddude wants to merge 1 commit into
Conversation
Since PR #102, GetLatestBlock returns (0, nil) for a missing key instead of an error. CatchupWorker.loadCatchupProgress still treated 0 as a real indexed block, so starting a new chain queued a catchup range from block 1 to chain head (millions of sub-ranges) and hung batch-saving them. Skip range creation when latest == 0: a cold start has no prior progress to catch up from; the regular worker anchors on chain head instead. Fixes #104
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.
Problem
Fixes #104 — regression from #102.
PR #102 changed
GetLatestBlockto return(0, nil)for a missing key (cold start) instead of an error.CatchupWorker.loadCatchupProgresswas not updated: it sawerr == niland treatedlatest = 0as a real indexed block, so starting a brand-new chain queued a catchup range from block 1 to chain head — on BSC that's ~109M blocks split into ~5.4M sub-ranges — and hung batch-saving them to the KV store, while also being set up to re-index the whole chain from genesis.Changes
internal/worker/catchup.go: skip catchup-range creation whenlatest == 0— a cold start has no prior progress to catch up from; the regular worker anchors on chain head (as designed in fix: treat TLS errors as failover-worthy and remove unsafe start-block fallback #102). Also removed an unreachablehead <= latestbranch.internal/worker/regular_test.go: regression tests — cold start queues nothing; resume from KV queues exactly the gap.Audited all other workers (regular, rescanner, recovery, manual, mempool, bloom_sync) — no other call site assumes the old error-on-missing-key behavior.
Note for operators
Deployments that ran the broken build against a new chain may have millions of junk catchup ranges persisted in Consul/Badger — delete that chain's catchup keys before restarting.
go build ./...,go vet, and all tests in the affected packages pass.