ioredis cluster doesn't discover newly added nodes
See original GitHub issueI’m finding that ioredis cluster doesn’t discover newly added nodes. On my application startup all nodes in the cluster will be discovered but if I add another node later on ioredis doesn’t see it.
Here are my steps to reproduce:
- Start a set of redis instances with the redis
create-cluster
script: https://github.com/antirez/redis/tree/3.2.11/utils/create-cluster - Create a cluster using the same script
- Start an ioredis client with this example script: https://gist.github.com/stephendeyoung/79910f6e2970ca163f9dd38d51776d6b. The script will seed Redis with 120000 keys that are distributed amongst the cluster. Then every five seconds it will count the number of keys across the whole cluster. Initially it counts the correct number of keys.
- Start a new redis-server like this:
redis-server --port 30007 --cluster-enabled yes --cluster-config-file nodes-30007.conf --cluster-node-timeout 2000 --appendonly yes --appendfilename appendonly-30007.aof --dbfilename dump-30007.rdb --logfile 30007.log --daemonize yes
- Use the
redis-trib.rb
script to add the new node to the cluster:redis-trib.rb add-node 127.0.0.1:30007 127.0.0.1:30001
- Reshard the cluster:
redis-trib.rb reshard 127.0.0.1:30001
- The script will continue to log the number of keys in the cluster but after resharding rather than counting 120000 keys it will count less than this
My expectation is that after adding the new node and resharding redis, ioredis will discover the new node and continue to count the correct number of keys.
Am I correct in expecting this behaviour? Please let me know if I’ve done anything wrong here.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
redis - Can ioredis client continue working if a cluster node ...
When connecting to a cluster, ioredis will ask the :7000 for the node list of the cluster, and after that ioredis is able...
Read more >Troubleshoot connecting to an ElastiCache for Redis cluster
If you recently created the cluster, verify that the cluster creation completed and that the cluster is ready to accept connections.
Read more >ioredis | Yarn - Package Manager
A robust, performance-focused and full-featured Redis client for Node.js. redis, cluster, sentinel, pipelining. readme. ioredis. Build Status Coverage Status ...
Read more >luin/ioredis - Gitter
A delightful, performance-focused Redis client for Node and io.js. People. Repo info.
Read more >ioredis - npm
When a new Redis instance is created, a connection to Redis will be created ... the list does not need to enumerate all...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve ended up doing that in my client app: periodically do CLUSTER SLOTS and compare the number of nodes with #nodes(). If #nodes < CLUSTER SLOTS nodes, then I do a cluster.disconnect(true) which appears to work. Though this doesn’t handle some odd scenario where a slave was moved from one master to another. And it has the downside of temporarily making redis unavailable to the app. It would be better if ioredis could handle this without causing the app to disconnect from the cluster.
What I noticed is if I killed a node, ioredis would shortly after completely remove that node from it’s list (#nodes().length would decrement). So even when the node recovers and rejoins the cluster, ioredis doesn’t reconnect to that node (unless a MOVED or ASK error is received which normally would not happen in a simple node failure / recovery scenario).
Chris
On Fri, Feb 16, 2018 at 8:23 PM, Zihua 子骅 notifications@github.com wrote:
I have that issue as well, in Sep 2022 😦