feat(health): detect stalled newHeads subscriptions (WS-only health signal)#9
Merged
Merged
Conversation
vixy reported upstreams healthy while their newHeads subscription had silently stalled, so WebSocket relay clients were served a frozen head for minutes. Observed on hoodi: an mk1 sequencer (WS) and taiko-driver (HTTP) both froze at the same L1 block while vixy's own monitor saw fresh blocks and reported every node healthy. Add a per-EL-node newHeads liveness probe plus a separate, WebSocket-only `subscription_healthy` signal: - New health::subscription probe maintains vixy's own newHeads subscription to each upstream and records the time of the last head. Freshness = time-since-last-head (subscription_stall_timeout_ms), independent of max_el_lag and the HTTP poll. - subscription_healthy gates ONLY WS relay selection (select_el_ws_node); it is never folded into is_healthy, so a stalled subscription never diverts HTTP traffic or flips the failover flag. - WS selection prefers fresh+healthy primary, then any fresh+healthy node (backups included), then falls back to plain health selection (never worse than HTTP). - Probe stall timer keys on the last head, not any frame, so WS keepalive pings don't mask a stall; capped exponential reconnect backoff + connect timeout; rejected subscriptions are logged clearly. - Expose sub_block_number/subscription_healthy in /status and a gated el_node_subscription_healthy metric. Config-validated; defaults on. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
vixy can report an EL upstream as healthy while its
newHeadssubscription has silently stalled, so WebSocket relay clients are served a frozen head for minutes. Observed in production on hoodi: an mk1 sequencer (WS) andtaiko-driver(HTTP) both froze at the same L1 block while vixy's own monitor saw fresh blocks (viaeth_blockNumberpolling) and reported every node healthy with zero errors.Root cause: health came only from HTTP polling, and the relay blindly forwarded whatever the upstream subscription delivered — there was no detection of a stalled subscription.
What this PR adds
A per-EL-node
newHeadsliveness probe and a separate, WebSocket-onlysubscription_healthysignal.health::subscriptionprobe — vixy maintains its ownnewHeadssubscription to each upstream and records the time of the last head. Detection is time-since-last-head (subscription_stall_timeout_ms), independent ofmax_el_lagand the HTTP poll.subscription_healthyis consulted ONLY by WS relay selection (select_el_ws_node). It is never folded intois_healthy, so a stalled subscription never diverts HTTP traffic or flips the failover flag./statusnow exposessub_block_number+subscription_healthy; theel_node_subscription_healthymetric is emitted only when the probe is actually tracking a node (not falsely1when disabled / never-connected).subscription_stall_timeout_ms > 0when enabled); defaults on (setsubscription_health_enabled = falseto disable).Behavior on the incident
Polled head 2930983 while the relayed subscription was frozen at 2930965 → the probe sees no head within the stall timeout → the node is marked subscription-stale → the WS relay fails over to a fresh node, HTTP routing untouched. Previously this was a ~4-minute silent frozen head.
Findings addressed (from review of the initial approach)
The key fix is decoupling subscription health from
is_healthyso it cannot cause HTTP over-failover or flip the global failover flag. Also: detection switched to time-since-last-head (so thesubscription_stall_timeout_msknob actually drives detection and no longer reusesmax_el_lag); the stall timer keys on heads not frames;sub_block_numberstores the latest head (not a monotonic max, so reorgs/resyncs don't permanently disable detection); capped backoff + connect timeout; subscribe-error logging; honest metric //statussemantics; config validation.Deliberately not changed (low value / higher risk — happy to do if preferred)
el_nodeswrite-lock + name lookup inrecord_head— runs at block cadence (~1 per 12s) over a handful of nodes; negligible. Per-node atomics were rejected becauseElNodeStatemust stayClonefor/statussnapshots.connect_async+ a subscribe send + anewHeadsparse).Testing
cargo fmt --checkandcargo clippy -- -D warnings— cleancargo test— 109 passed (incl. new tests for freshness, backoff, WS selection, head parsing, subscribe-error detection)cargo test --test cucumber— 16 scenarios / 83 stepscargo build --release— clean🤖 Generated with Claude Code