Open
Conversation
The catchup worker exited permanently when its initial ranges were empty or completed. This meant ranges created later by the regular worker's skipAheadIfLagging were never picked up until service restart, causing pending blocks to accumulate without being processed. Now the worker polls the block store every 5 seconds for new ranges instead of returning.
loadCatchupProgress was creating new catchup ranges when none existed in the store. This caused an infinite cycle: ranges were created, processed, deleted from store, then recreated on the next reload — inflating the in-memory catchup_pending_blocks counter with phantom ranges that no longer existed in Consul. Range creation is the responsibility of the regular worker (via determineStartingBlock or skipAheadIfLagging). The catchup worker should only load and process existing ranges.
vietddude
approved these changes
Apr 3, 2026
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.
Fix: Catchup worker not processing pending blocks & phantom range accumulation
Problem
Two related bugs in the catchup worker caused
pending_blocksto accumulate without being processed, particularly affecting fast chains like Aptos:Catchup worker exited permanently after processing initial ranges. When the regular worker later created new catchup ranges via
skipAheadIfLagging, nothing picked them up until the servicewas restarted.
loadCatchupProgresscreated phantom catchup ranges on reload. When no ranges existed in Consul, it created new ones, processed them, deleted them from Consul, then recreated them on the nextreload — an infinite cycle that inflated the in-memory
catchup_pending_blockscounter. This caused the status API to report ~100 pending blocks even though Consul had zero catchup ranges.Root Cause
runCatchup()calledreturnwhenblockRangeswas empty, killing the goroutine permanently.loadCatchupProgress()had dual responsibility: loading existing ranges AND creating new ones. On reload after processing, it always found an empty store and created new ranges, causing a desyncbetween Consul (source of truth) and the in-memory status registry.
Changes
runCatchup(): Instead of exiting when ranges are empty, the worker now polls the block store every 5 seconds for new ranges. It only exits on context cancellation (service shutdown).loadCatchupProgress(): Removed range creation logic. The function now only loads existing ranges from the store. Range creation remains the sole responsibility of the regular worker(
determineStartingBlock/skipAheadIfLagging).Impact
catchup_pending_blockscounter stays in sync with the actual Consul state.healthystatus instead ofdegraded/slowdue to phantom pending blocks.