Repository navigation
fix(redis): Retry cluster client creation when no startup node is reachable - #132097
Draft
sentry-junior[bot] wants to merge 3 commits into
Draft
sentry-junior[bot] wants to merge 3 commits into
sentry-junior[bot] wants to merge 3 commits into
Conversation
A short network blip can leave every Redis Cluster startup node unreachable, which fails CLUSTER SLOTS and the work that triggered it. Retry NodeManager.initialize twice with a short jittered backoff when that happens. CLUSTER SLOTS is read-only, so the retry is safe even mid-write. Co-Authored-By: Kyle Consalus <6990351+kcons@users.noreply.github.com>
kcons
reviewed
Nov 21, 2026
…ager Build the cluster client through a small retrying constructor rather than patching the node manager's initialize method on each client.
… switch A failed attempt has usually already waited out the socket timeout on each unreachable startup node, so retry once immediately. Add redis.cluster.create-retry.enabled so the retry can be turned off without a deploy. Co-Authored-By: Kyle Consalus <6990351+kcons@users.noreply.github.com>
This branch has not been deployed
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.
A short network blip can leave every Redis Cluster startup node unreachable. When that happens, redis-py-cluster raises
RedisClusterException: Redis Cluster cannot be connectedwhile the client is being created, and whatever first touched the lazy client fails with it. That can be a task, a consumer, a request, or bookkeeping in the middle of a write where retrying the whole unit of work isn't an option.cluster_factorynow builds the client through_create_cluster_with_retry. On the "cannot be connected" error, it retries theRetryingRedisCluster(...)call once, right away. There's no sleep, because a failed attempt has usually already waited outsocket_timeout(3s) on each unreachable startup node. Creating a client only reads cluster topology (CLUSTER SLOTS), so the retry can't double-apply a caller's write. The retry re-copies the startup nodes, because redis-py-cluster mutates them. Each retry incrementsredis.cluster.create.retry.redis.cluster.create-retry.enabled(defaultTrue, automator-modifiable) is a kill switch: if the retry makes an outage worse, it can be turned off without a deploy. The option is only read after a failed first attempt.This covers creating the client only. Slot refreshes on a client that already exists (
reset()after connection errors, and reinitialization from commands and pipelines) still raise right away.Open decision:
RedisClusterExceptionfor every case, so this keys off the message prefix. Other creation failures, such as slot disagreement or incomplete coverage, still raise right away. If an attempt fails fast instead of timing out (for example connection refused), the retry happens almost immediately, with no real delay.via @kcons.
--
View Session [Sentry]