feat: harden the Redis connection for distributed runs - #24
Merged
Conversation
SpecBandit's Redis is a best-effort coordinator for a distributed run, but CI runners can sit a WAN hop away from it (e.g. a cross-datacenter Kilo mesh). A transient blip was reddening backend-spec shards with `[specbandit] Redis error: ... (Redis::TimeoutError)` even though the Redis server was healthy — the connect just timed out over the inter-DC tunnel. - Explicit client resilience: pass connect/read/write timeouts and reconnect_attempts to `Redis.new` instead of relying on library defaults. - Larger, configurable retry budget: MAX_ATTEMPTS default raised 3 -> 5 and made env/flag-driven (SPECBANDIT_REDIS_MAX_ATTEMPTS / --redis-max-attempts), with capped (10s) exponential backoff so short blips are ridden out. Bumps the gem to 1.1.0.
beagleknight
force-pushed
the
feat/redis-resilience-fallback
branch
from
July 16, 2026 11:21
4d72b98 to
f7beb55
Compare
beagleknight
marked this pull request as ready for review
July 16, 2026 12:34
fcsonline
approved these changes
Jul 16, 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.
Why
Backend-spec shards in
factorialco/factorialCI intermittently fail with:The Redis server is healthy — it's a network-path problem. SpecBandit's shared Redis is pinned to one node in one datacenter (Kilo location
hel), and ~1/3 ofbuild-lrunners now live in a different DC (fsn1, added 2026-07-01) and reach Redis over an inter-DC WireGuard tunnel (~29 ms vs ~5 ms intra-DC). A transient blip on that tunnel exhausts SpecBandit's short retry budget andworkexits 1, reddening the build.What
Harden the Redis connection so short blips are ridden out instead of failing the run:
redis_queue.rb):Redis.newnow getsconnect_timeout/read_timeout/write_timeout+reconnect_attemptsinstead of bare library defaults.configuration.rb,redis_queue.rb):MAX_ATTEMPTSdefault 3 → 5, env/flag-driven (SPECBANDIT_REDIS_MAX_ATTEMPTS/--redis-max-attempts), with capped (10s) exponential backoff.No behavioural change when Redis is reachable; on a hard outage
workstill fails loudly as before (never a silent pass).Notes for review
specbanditjskeeps the two implementations in sync.Tests
bundle exec rspec spec/specbandit spec/integration→ 126 examples, 0 failures (integration pending only without a local Redis). Added connection-option, env-config, and configurable-retry (incl. custommax_attempts) coverage inredis_queue_spec.rb/configuration_spec.rb.Draft for review.