-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hello,
I'm a bit confused by the "+node" event in cluster mode and wanted to check if I'm misunderstanding what it represents.
I'm using the ioredis.Cluster
object to connect to a Redis cluster, and I'm trying to listen to the events it emits to improve the monitoring of connection errors.
According to the root README, the "+node" event is emitted by Cluster
when a "when a new node is connected".
I think this is slightly confusing, here is the scenario I am working with:
- A node gets disconnected
- I try to send a command to my cluster, and that command needs to talk to the disconnected node
Cluster
creates a new instance ofRedis
to connect to the node (code)- Note that this connection is created with
lazyConnect: true
by default, so the connection is not actually established straight away (code) - A handler is attached to the "end" event in order to deal with future connection issues (code)
- The "+node" event is emitted (code). Note how this is emitted now, but we have not actually established a connection yet, hence my confusion with the documentation.
Now my command tries to run. But imagine the node is still unreachable for whatever reason:
- We receive some kind of error
Redis
instances in cluster mode are configured to not retry connecting by default, soRedis
fires its "end" eventCluster
fires the "-node" event
What I'm seeing in this scenario is a long list of "+node", "-node", "+node", etc. events, until the Cluster
decides to stop completely. This long list of events makes debugging difficult, because it seems to imply that we are successfully connecting to the node, but quickly getting disconnected, and so on.
TL;DR
If I'm not mistaken, the "+node" event is emitted when Cluster
has added a new instance of Redis
to its connection pool, but that doesn't mean a successful connection to the node has been established yet.
Is this correct? If so, should the documentation be updated to clarify this? I would be more than happy to open a PR with a suggestion.
Many thanks!