Skip to content

feat: harden the Redis connection for distributed runs - #24

Merged
beagleknight merged 1 commit into
mainfrom
feat/redis-resilience-fallback
Jul 16, 2026
Merged

feat: harden the Redis connection for distributed runs#24
beagleknight merged 1 commit into
mainfrom
feat/redis-resilience-fallback

Conversation

@beagleknight

@beagleknight beagleknight commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Why

Backend-spec shards in factorialco/factorial CI intermittently fail with:

[specbandit] Redis error: Error connecting to Redis on redis-ci-master.redis-ci.svc.cluster.local:6379 (Redis::TimeoutError)

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 of build-l runners 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 and work exits 1, reddening the build.

What

Harden the Redis connection so short blips are ridden out instead of failing the run:

  • Explicit client resilience (redis_queue.rb): Redis.new now gets connect_timeout / read_timeout / write_timeout + reconnect_attempts instead of bare library defaults.
  • Configurable retry budget (configuration.rb, redis_queue.rb): MAX_ATTEMPTS default 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 work still fails loudly as before (never a silent pass).

Notes for review

  • Version bumped to 1.1.0 — adjust if it conflicts with your release flow.
  • Mirror PR in specbanditjs keeps 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. custom max_attempts) coverage in redis_queue_spec.rb / configuration_spec.rb.

Draft for review.

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
beagleknight force-pushed the feat/redis-resilience-fallback branch from 4d72b98 to f7beb55 Compare July 16, 2026 11:21
@beagleknight beagleknight changed the title feat: Redis resilience + graceful degradation in work feat: harden the Redis connection for distributed runs Jul 16, 2026
@beagleknight
beagleknight marked this pull request as ready for review July 16, 2026 12:34
@beagleknight
beagleknight merged commit 7206e40 into main Jul 16, 2026
3 checks passed
@beagleknight
beagleknight deleted the feat/redis-resilience-fallback branch July 16, 2026 12:36
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.

2 participants