Repository navigation
fix: cap dead-letter retries and classify permanent fetch errors - #5
Merged
Merged
Conversation
The in-run dead-letter sweep re-queued failed heights forever because nothing ever consulted the `retries` counter and every error looked the same. On a live indexer this manifested as 10k+ heights cycling through the sweep every ~55 min with zero convergence. Changes: * Typed sentinels `rpc.ErrNoEndpointCovers` and `rpc.ErrHeightPruned` carry structured context and match via `errors.Is` through wrapping. LCD 400/404 on block paths are promoted to `HeightPrunedError` via a new `HTTPStatusError` wrapper. * `internal/pipeline/classify.go` splits fetch errors into permanent vs transient. Permanent errors fast-path in `processWithSplit` — no bisection; every height in the range is recorded as permanent in a single pass. * Additive migration on `indexer_failures`: `permanent BOOLEAN NOT NULL DEFAULT FALSE`, `max_retries_reached_at TIMESTAMPTZ`, plus a partial-friendly index. `ALTER TABLE … ADD COLUMN IF NOT EXISTS` so existing deployments upgrade on startup. * `failure_max_retries` (default 5): promotion to `permanent = true` happens server-side in the `RecordFailure` UPSERT via a CASE, no RMW race. * `PopFailures` filters `permanent = FALSE` — permanent rows stay for operator review but never rejoin the carousel. * `FailureCount` returns `(retrying, permanent, maxRetries)`; the UI surfaces both counts as "N retrying · M permanent".
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
failure_max_retriescap (default 5) that promotes rows topermanent = trueserver-side in theRecordFailureUPSERT, and an additive schema migration onindexer_failures.PopFailuresexcludes permanent rows so the sweep stops spending fetch budget on unrecoverable heights; permanent rows stay in the table for operator review. UI splits "N dead-letter ranges" into "N retrying · M permanent".How the classification works
rpc.ErrNoEndpointCovers(no eligible endpoint for requested range)rpc.ErrHeightPruned(LCD 400/404 on block path)ErrRateLimited, 5xx, timeouts, network errorsSchema migration
Applied on startup via
ensureFailuresTable. Existing rows default topermanent = falseand continue behaving exactly as before.Config
Test plan
go build ./...cleango vet ./...cleanTEST_DATABASE_URL(pop-filter, cap-promotion, no-cap-never-promotes, legacy-row migration,RecordPermanentFailureinsert+upgrade)