Description
#slots.rediscover() is correctly called when MOVED or ASK reply is received:
|
} else if (err.message.startsWith('MOVED')) { |
|
if (err.message.startsWith('ASK')) { |
there is a problem / race-condition on scale-down cluster (rebalance hash slots away, forget node, shutdown):
#slots.rediscover() might never be called, if the leaving node has not been queried (after it's slots migrated away) before shutdown (hence it never got a chance to reply with MOVED and trigger a rediscover)
this results in connection closed errors, because node-redis cluster.#slots is keeping a client active for an outdated cluster topology.
steps to reproduce:
- start a redis cluster
- create node-redis client and connect
- redis-cli reshard all slots away from a redis cluster node
- redis-cli del-node the now empty node, then shutdown
- node-redis client execute command for a key, which is sharded the (now shutdown) node
connection closed error
an option to fix this would be to provide an option for a slot refresh interval (ioredis does this too), will send a pull request
Node.js Version
No response
Redis Server Version
No response
Node Redis Version
No response
Platform
No response
Logs
No response
Description
#slots.rediscover()is correctly called whenMOVEDorASKreply is received:node-redis/packages/client/lib/cluster/index.ts
Line 271 in 6f79b49
node-redis/packages/client/lib/cluster/index.ts
Line 256 in 6f79b49
there is a problem / race-condition on scale-down cluster (rebalance hash slots away, forget node, shutdown):
#slots.rediscover()might never be called, if the leaving node has not been queried (after it's slots migrated away) before shutdown (hence it never got a chance to reply with MOVED and trigger a rediscover)this results in
connection closederrors, because node-rediscluster.#slotsis keeping a client active for an outdated cluster topology.steps to reproduce:
connection closederroran option to fix this would be to provide an option for a slot refresh interval (ioredis does this too), will send a pull request
Node.js Version
No response
Redis Server Version
No response
Node Redis Version
No response
Platform
No response
Logs
No response