fix(redis): make Sentinel clients resilient to dropped connections - #403
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the robustness of Redis client creation in Remoulade by configuring health checks and automatic retries for both Sentinel-based and direct Redis URL connections, across sync and async clients. This prevents transient connection resets (including Sentinel master discovery blips) from surfacing as persistent failures.
Changes:
- Introduces shared connection defaults (health checks, TCP keepalive, and retry policy) via a helper in
redis_client.py. - Applies the same resiliency parameters to Sentinel node connections and master connections for both sync and async Redis clients.
- Adds tests asserting these connection parameters are set for Sentinel URLs, plain Redis URLs, and the no-
socket_timeoutscheduler-style configuration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
remoulade/helpers/redis_client.py |
Centralizes and applies Redis connection resiliency defaults (health checks + retries) for sync/async and Sentinel/plain URL paths. |
tests/test_helpers.py |
Adds unit tests validating resilient connection kwargs are configured on created Redis clients. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
etiennecrb
marked this pull request as ready for review
July 7, 2026 07:34
etiennecrb
force-pushed
the
fix/redis-sentinel-client-resilience
branch
from
July 8, 2026 10:09
d5462b0 to
c06c1df
Compare
Redis backends built via redis_client()/async_redis_client() opened Sentinel connections with no health check and no retry, so a transient connection reset (Connection reset by peer on the Sentinel port) surfaced as MasterNotFoundError even though a healthy master existed. Set health_check_interval, socket_keepalive and a retry on ConnectionError/ TimeoutError on both the Sentinel-node and master connections, for the sync and async clients and the plain (non-Sentinel) URL path. MasterNotFoundError is a ConnectionError, so discovery blips are now retried transparently. Applied unconditionally so the scheduler client (built without socket_timeout) is covered too.
etiennecrb
force-pushed
the
fix/redis-sentinel-client-resilience
branch
from
July 8, 2026 10:13
c06c1df to
ce4be1d
Compare
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.
Redis backends built via redis_client()/async_redis_client() opened Sentinel connections with no health check and no retry, so a transient connection reset (Connection reset by peer on the Sentinel port) surfaced as MasterNotFoundError even though a healthy master existed.
Set health_check_interval, socket_keepalive and a retry on ConnectionError/ TimeoutError on both the Sentinel-node and master connections, for the sync and async clients and the plain (non-Sentinel) URL path. MasterNotFoundError is a ConnectionError, so discovery blips are now retried transparently. Applied unconditionally so the scheduler client (built without socket_timeout) is covered too.