Skip to content

fix(redis): make Sentinel clients resilient to dropped connections - #403

Merged
etiennecrb merged 1 commit into
masterfrom
fix/redis-sentinel-client-resilience
Jul 8, 2026
Merged

fix(redis): make Sentinel clients resilient to dropped connections#403
etiennecrb merged 1 commit into
masterfrom
fix/redis-sentinel-client-resilience

Conversation

@etiennecrb

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_timeout scheduler-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
etiennecrb marked this pull request as ready for review July 7, 2026 07:34
@etiennecrb
etiennecrb force-pushed the fix/redis-sentinel-client-resilience branch from d5462b0 to c06c1df Compare July 8, 2026 10:09
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
etiennecrb force-pushed the fix/redis-sentinel-client-resilience branch from c06c1df to ce4be1d Compare July 8, 2026 10:13
@etiennecrb
etiennecrb merged commit 4cb45d3 into master Jul 8, 2026
4 of 7 checks passed
@etiennecrb
etiennecrb deleted the fix/redis-sentinel-client-resilience branch July 8, 2026 13:02
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