Harden Resque post-fork reconnect against saturated Redis (maxclients) [179D-310] - #874
Merged
Merged
Conversation
Stock resque 2.6 Worker#reconnect only retries Redis::BaseConnectionError. A saturated Redis accepts the socket and replies "-ERR max number of clients reached" (Redis::CommandError), so the forked child dies on its first Redis use with no retry - and reporting the failure needs Redis too, so the job vanishes unrecorded and InitializeAnalysis strands its analysis in 'queued' forever (2026-08-18 k8s outage: large spot worker fleet pushed connected_clients past maxclients). - config/initializers/resque_reconnect_retry.rb: prepend override that also retries Redis::CommandError (covers maxclients and AOF LOADING), 5 tries with backoff (~30s total), then re-raises into the stock failure path; no-op in delayed_job deployments (guarded on defined?(Resque::Worker)); retry count tunable via RESQUE_RECONNECT_RETRIES - spec/lib/resque_reconnect_retry_spec.rb: unit specs, tagged depends_resque (resque only loads in resque envs); wired into the docker CI job via docker/server/run-server-tests.sh - verified in a local replica of the CI docker env (nrel/openstudio-server:develop + mongo as db + redis as queue): 6 examples, 0 failures Co-Authored-By: Claude Fable 5 <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.
Cherry-pick of #873 onto the
179D-310test branch (clean pick off13e0c8c, no conflicts), so the fix rides the3.10.0-179D-testimages.Problem
During the 2026-08-18 k8s deploy testing on the 179D-310 images, every
analysis_wrappersjob popped between 13:44 and 13:55 UTC vanished without a trace, stranding six analyses inqueuedforever (and losing threeFinalizeAnalysisruns). The resque log showed:Root cause chain:
connected_clientspastmaxclients.Resque::Worker#reconnect). Stock resque 2.6 only retriesRedis::BaseConnectionErrorthere — but a saturated server accepts the socket and replies-ERR max number of clients reached, which redis-rb raises asRedis::CommandError. No retry: the child dies ~4ms aftergot:.job.failand the failed counter also throw — the job is never recorded anywhere, and the analysis sits inqueuedwith no terminal state.The capacity side is being fixed in the helm chart (
redis.maxclients, keepalive/timeout). This PR is the app-side hardening so a brief saturation window degrades to a short wait instead of silent job loss.Change
server/config/initializers/resque_reconnect_retry.rb— prepends an override ofResque::Worker#reconnectthat also retriesRedis::CommandError(covers maxclients saturation and-LOADINGduring AOF replay after a redis restart), 5 tries with increasing backoff (~30s total), then re-raises into the stock failure path. No-op in delayed_job deployments; retry count tunable viaRESQUE_RECONNECT_RETRIES.server/spec/lib/resque_reconnect_retry_spec.rb— unit specs, taggeddepends_resque.docker/server/run-server-tests.sh— runs the new spec in the docker (resque) CI job.Testing
Verified in a local replica of the CI docker environment using the 3.10 image lineage of this branch (
nrel/openstudio-server:3.10.0+mongo:8.0.12asdb+redis:6.0.9asqueue,RAILS_ENV=docker): 6 examples, 0 failures. Same result on the develop image (see #873).🤖 Generated with Claude Code