Cluster: a node client whose reconnectStrategy gave up after connecting is returned forever
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, redis, typescript
- 領域
- database
調査の方向性
Start in the cluster slots implementation at nodeClient() and read how #discover handles clients whose addresses leave the topology; the gap is the connected-then-gave-up state. Check the client state predicates used to distinguish open/ready from draining after close()/QUIT, then reproduce with the SIGSTOP/SIGCONT three-node scenario. Done means a closed node client is destroyed and replaced on next use, with a spec covering both the replaced client and a draining client.
索引モデルが issue の本文から書いたものです。
説明
Description
In a cluster, when a node's client connects and later gives up reconnecting, RedisClusterSlots.nodeClient() keeps returning that closed client. Every command for the node's slots then fails with ClientClosedError ("The client is closed") until the whole cluster client is rebuilt. Nothing in the client recovers it: #discover only drops clients for addresses that have left the topology, and nodeClient() only creates a client when node.client is unset.
#3396 / #3403 fixed the first-connect variant. This is the variant where the client was connected first. Follow-up to #3656, as asked there.
On "socketTimeout is set far higher than a one-minute stall": in our production it isn't. We run socketTimeout: 12_000, so we notice a dead or half-open connection quickly instead of leaving commands hanging. Our shards stall for about a minute at a time (Azure Managed Redis, during platform-side CPU spikes, several times a day), which is longer than 12 s. And the problem isn't how often it happens: any stall longer than socketTimeout, whatever the value, leaves that node unusable for good, with no recovery short of rebuilding the cluster client. A higher timeout makes it rarer but no less permanent.
Impact in production: across our backend services, about 97% of our Redis errors were this "client is closed" tail rather than the stall itself. A stall of about one minute became 5–45 minutes of errors per pod, ending only when a pod restarted or our own health check happened to rebuild the client.
Client configuration (cluster defaults; RESP2, Entra ID credentials provider, TLS):
{
pingInterval: 10_000,
socket: {
connectTimeout: 5_000,
socketTimeout: 12_000,
keepAlive: true,
keepAliveInitialDelay: 5_000,
// same rule as the default strategy: give up on SocketTimeoutError, otherwise back off
reconnectStrategy: (retries, cause) =>
cause instanceof SocketTimeoutError ? false : Math.min(2 ** retries * 50, 2000) + jitter,
tls: true,
},
}
// commandOptions: { timeout: 8_000 }
Reproduction: a 3-node local cluster with the configuration above (without TLS/Entra). Freeze one node with SIGSTOP for 60 s while its keys get no traffic, so its socket goes idle past socketTimeout, then SIGCONT it:
- 5.12.0: every command for the frozen node's slots fails with
ClientClosedErrorfor 199 s+ after the unfreeze, until the run ended. - With the change below: 0 errors after the unfreeze; the next command reconnects the node.
Proposed approach: in nodeClient(), if node.client exists and is neither open nor ready (so it gave up, rather than draining after close()/QUIT), destroy and unregister it and create a fresh one. That's what #3656 does, including a spec for a draining client. Happy to reopen it or rework the approach if you agree.
Node.js Version
v22.23.4
Redis Server Version
Azure Managed Redis (MemoryOptimized_M20, OSS cluster policy); reproduced locally on redis:7-alpine
Node Redis Version
@redis/client 5.12.0; master's nodeClient() behaves the same
Platform
Linux (Azure Container Apps)
Logs
# one shard stalls past socketTimeout
Error: Socket timeout timeout. Expecting data, but didn't receive any in 12000ms.
# then, for every command on that shard's slots until the cluster client is rebuilt
ClientClosedError: The client is closed
- 主要言語
- TypeScript
- スター
- 17.6k
- フォーク
- 2k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 62
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
redis/node-redis のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
redis/node-redis#3664 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
After a MOVING handoff, a client never becomes ready again on reconnect対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
redis/node-redis#3705 ·
メンテナーはふだん 1 日以内に返信
-
Support Uint8Array values for zero-copy transfer to worker_threads対応中かも @umeshmore45 が 286 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
redis/node-redis#3106 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
`RedisClientType` type is slow to typecheck (TS performance issue)再び着手できるかも @nkaradzhov が 556 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンBug
redis/node-redis#2975 · コメント 30 件 · リアクション 27 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
redis/node-redis#2855 · コメント 4 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
redis/node-redis の issue をすべて見る
似ている issue
-
agent/guide documentation help wanted stage/010-actionable
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
kubestellar/console-marketplace#1101 ·
メンテナーはふだん 1 日以内に返信
-
Java Edition Tests
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
JSPrismarine/JSPrismarine#4178 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
totec448-spec/chat-on-steroids#2394 ·
メンテナーはふだん 1 日以内に返信
-
github_actions
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
StellarHyperion/stellarhyperion-backend#499 ·
メンテナーはふだん 1 日以内に返信