Repository navigation
fix(reference-index): keep transient sync failures retryable - #149
Conversation
`synchronize_once` latched the runtime phase to `Unavailable` on every error, while `run` classifies errors with `requires_manual_rebuild` and retries everything else with backoff. The two used different criteria, so a transient failure (provider read, short canonical batch, MDBX hiccup) gated the read path even though catch-up was still in progress. `query_at` short-circuits on `Unavailable` before any cursor comparison, so during the backoff window (1s up to 30s) queries returned `IndexUnavailable` — which tells clients to stop retrying — even when the durable cursor already matched the canonical tip and the answer was servable. The RPC handler compounds this: `IndexUnavailable` bypasses the bounded server-side catch-up wait that `IndexBehind` is granted. Gate the phase on `requires_manual_rebuild` so only unrecoverable errors (corrupt metadata, chain identity or schema mismatch, missing post-Jade ancestor) reach `Unavailable`. Transient errors leave the phase where the turn left it, letting the cursor-vs-tip comparison surface `IndexBehind`. No correctness change: the index never served stale rows in either case, and `Unavailable` was already cleared by the next successful turn.
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
synchronize_oncelatched the runtime phase toUnavailableon every error:Meanwhile
run(runtime.rs:393-403) classifies errors withrequires_manual_rebuild()and retries everything else with exponential backoff(1s up to 30s). The two sites used different criteria for the same question,
so a transient failure — a provider read error, a short canonical batch, an MDBX
hiccup — gated the read path even though catch-up was still in progress and
would succeed on the next turn.
The read path makes this visible:
query_atshort-circuits onUnavailable(
reader.rs:157) before any cursor comparison. During the backoff window,queries therefore returned
IndexUnavailable— which tells clients to stopretrying — even when the durable cursor already matched the canonical tip and
the answer was fully servable. The RPC handler compounds it:
IndexUnavailabletakes the
Err(other) => returnpath (handler.rs:237) and so bypasses thebounded server-side catch-up wait that
IndexBehindis granted.Fix
Gate the phase on the same predicate
runalready uses, so only unrecoverableerrors reach
Unavailable:CorruptMetadataChainIdentityMismatchSchemaMismatchManualRebuildRequiredTransient errors leave the phase where the turn left it, letting the
cursor-vs-tip comparison surface
IndexBehind— the retryable signal — on itsown.
Leaving the phase untouched is safe on every path: stopped at
Livewith amatching cursor the data is genuinely valid and serves; a lagging cursor yields
IndexBehind; a first-timeopen_dbfailure keepsOpeningwith no installedDB, which yields
Initializing.The
Unavailableset inrunwhen the blocking task dies unexpectedly(
runtime.rs:370) is unchanged — that path returns without further retries, sothe gate is correct there.
Impact
No correctness change. The index never served stale rows in either case, and
Unavailablewas already non-sticky (set_phaseclears theunavailableflagon the next successful turn). This only removes a false-negative window where a
servable index refused queries and told clients not to come back.
Tests
incomplete_provider_batch_does_not_advance_the_cursor— updated to assert thephase is not polluted to
Unavailableby a transient short batch; the cursorassertion is unchanged.
transient_failure_leaves_queries_retryable— new; asserts the read pathanswers
IndexBehindrather thanIndexUnavailableafter a transient failure.reorg_reaching_below_finalized_is_bounded_to_a_manual_rebuildandreorg_without_a_post_jade_ancestor_requires_a_manual_rebuild— unchanged, andnow serve as regression protection for the unrecoverable branch.
Summary by CodeRabbit