Skip to content

fix(node): retry a transient eth_getLogs window inside the poller tick - #2163

Merged
thiras merged 3 commits into
mainfrom
fix/2161-getlogs-window-retry
Sep 25, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2161-getlogs-window-retry

Conversation

@thiras

@thiras thiras commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What

The shared chain-event poller failed the whole tick on the first non-range eth_getLogs error. On the dRPC free plan (100-block cap, ~15–20 % of calls failing with code 19 / 30, ≥ 2 windows per 30 s tick) that fed back on itself: failed tick → backoff → bigger backlog → more windows → lower P(tick succeeds). Every watcher showed 3.5–12 min down_seconds peaks although no event was lost.

run_tick now fetches each window through fetch_window_logs, which retries a transient failure on the same block range up to 2 times, 2 s apart, before the tick fails:

  • A retry that succeeds is a plain success: no on_backoff, no restart count, no down_since change.
  • Range rejections keep the existing shrink path. A permanent error (is_permanent_rpc_error: revert, invalid request/method/params, HTTP 4xx other than 408/429) and a rate limit (is_rate_limit: HTTP 429, Retry-After, rate-limit wording) fail the tick at once, so a used-up quota gets the loop's exponential backoff, not fixed 2 s retries.
  • Each retry logs its cause at info, so an operator can tell a flaky provider from windows that are too wide (timeouts).
  • The retry sleep is shutdown-aware (ends the tick like the per-window shutdown check).
  • Each retry (counted after its sleep; up to two per window) fires a new on_window_retry hook → decdn_chain_get_logs_retries_total, added to appendix-observability, the "eth_getLogs window span" dashboard panel, the flapping-alert description and the runbook.

Closes #2161

Reviewer notes

  • Read fetch_window_logs and is_transient_window_error in crates/node/src/chain_events/multiplexed_poller.rs first. The helper takes the poller's parts instead of &MultiplexedPoller because the poller is not Sync.
  • Retry count and delay are consts (GET_LOGS_WINDOW_RETRIES, GET_LOGS_WINDOW_RETRY_DELAY), not config knobs.
  • a_rate_limit_backs_off_and_keeps_the_window now also asserts that no retry happens (a queued success would otherwise complete the tick).
  • Worst case for a hung provider: 3 × 10 s timeout + 2 × 2 s = 34 s per window before the tick fails (documented in the module doc and runbook).
  • Out of scope, as in the issue: provider failover (Multi-RPC priority failover: blockchain.rpc_urls with sticky fallback #2156), scan confirmation lag, down_seconds semantics.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-node — 1354 passed. New tests cover: retry then success (delay applied); exhausted retries; per-window budget across a multi-window tick; a later exhausted window keeps earlier progress; retry then range rejection still shrinks; permanent error and rate limit not retried; shutdown during the retry sleep; classifier cases (dRPC 19/30, head lag, timeouts, 401, 429, Retry-After). Mutations: retries = 0 fails 6 tests; dropping the rate-limit exclusion fails 1.
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • pre-commit run on the changed files
  • contracts/ changed — n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: adr/appendix-observability.md metric row added
  • PR title uses an allowed type with a lowercase subject

Post-deploy check on testnet: decdn_*_watcher_down_seconds peaks drop, multiplexed poller tick error lines fall, and rate(decdn_chain_get_logs_retries_total) takes over as the flakiness signal.

🤖 Generated with Claude Code

The shared chain-event poller failed the whole tick on the first non-range
get_logs error. On a flaky provider that fed back on itself: a failed tick
backs off, the backlog grows, the next tick needs more windows, and each
window is another chance to fail. On the dRPC free plan every watcher showed
minutes of downtime although no event was lost.

A transient window failure now retries the same block range up to two
times, 2 s apart, before the tick fails. A retry that succeeds fires no
route hook. Range rejections keep the shrink path, and a permanent JSON-RPC
error (is_permanent_rpc_error) still fails the tick at once. Each retry
bumps the new decdn_chain_get_logs_retries_total counter, plotted beside
the range rejections on the chain dashboard.

Closes #2161

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 25, 2026 19:10
@thiras thiras self-assigned this Sep 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address the two review comments about metric semantics and alert wording.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR adds bounded, shutdown-aware retries for transient eth_getLogs failures and exposes retry observability.

Changes:

  • Retries transient windows twice before failing a tick.
  • Adds retry metrics, dashboard visibility, alert/runbook guidance, and ADR documentation.
  • Adds classifier, shutdown, behavior, and metric wiring tests.
File Description
monitoring/​prometheus-alerts.yml Updates flapping alert guidance.
monitoring/​dashboard-chain.json Adds retry-rate visualization.
docs/​runbook.md Documents operational retry behavior.
crates/​node/​src/​runtime/​mod.rs Wires the retry metric hook.
crates/​node/​src/​metrics.rs Defines and exports the retry counter.
crates/​node/​src/​chain_events/​multiplexed_poller.rs Implements retry logic and tests.
CHANGELOG.md Records the user-visible change.
adr/​appendix-observability.md Registers the retry metric.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread monitoring/prometheus-alerts.yml Resolved
@github-code-quality

github-code-quality Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 33578cf in the fix/2161-getlogs-win... branch remains at 85%, unchanged from commit 88861ff in the main branch.

Show a line coverage summary of the most impacted files.
File main 88861ff fix/2161-getlogs-win... 33578cf +/-
crates/node/src/runtime/mod.rs 50% 50% 0%
crates/client/src/ledger.rs 99% 99% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src/metrics.rs 96% 96% 0%
crates/node/src...lexed_poller.rs 92% 93% +1%
crates/client/src/streamer.rs 91% 92% +1%

Updated September 25, 2026 19:39 UTC

- Do not retry a rate limit in place (HTTP 429, Retry-After, or rate-limit
  wording): it goes straight to the loop's exponential backoff instead of
  spending more of an exhausted quota.
- Log each retry and its cause at info, so an operator can tell a flaky
  provider from windows that are too wide without a debug restart.
- Count a retry after its sleep, so a retry that shutdown cancels is not
  counted.
- Say the counter counts retries (up to two per window), not windows, in
  the metric doc, ADR appendix, runbook and dashboard; point the flapping
  alert row and runbook bullet at it; note the 34 s worst case for a hung
  provider.
- Fix stale and changelog-voice docs in multiplexed_poller.rs.
- Tests: per-window retry budget across a multi-window tick, a later
  window that spends its retries keeps earlier progress, a retried window
  still shrinks on a range rejection, head-lag and rate-limit classifier
  cases, the retry delay is applied, and a rate limit is not retried.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Add -32007 rate-limit classification and check shutdown cancellation immediately after retry sleep.

Review effort: Lite
Findings: None

Resolved since last review (1)

@thiras
thiras merged commit ce98e34 into main Sep 25, 2026
31 checks passed
@thiras
thiras deleted the fix/2161-getlogs-window-retry branch September 25, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node: retry a transient eth_getLogs window failure inside the poller tick instead of failing every watcher

2 participants