-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redis Cluster: ioredis doesn't update cluster topology on redis instance restarts #1732
Comments
Hey @luin 👋 do you happen to know if this is a well-known problem? What are the current assumptions ioredis makes around cluster topology updates? |
Today by using the error and trial approach, I have been able to discover a hack that could mitigate this issue. So I put my listener into a endless retry loop like I explained in the issue description:
ioredis won't recover from this state by itself, but if you happen to send a ping() command, then the situation becomes interesting. At some point,
With an updated topology, ioredis will be able to work with redis cluster again. I have put this ping command to my healthiness probes like that: try {
await redisClient.ping();
res.status(200).send({ healthy: true });
} catch {
res.status(503).send({ healthy: false, message: 'Redis cluster is dead' });
} Given that Kubernetes requests healthiness probes periodically, this actually can mitigate the problem to a good extend. I'm surprised this hack was not suggested in numerous of related tickets I have seen during thinking of this problem. Hope this will help you to safe some time. |
When using
ioredis
for receiving messages from a redis cluster deployment (deployed using Bitnami Redis Cluster chart, for example), I have spotted a situation whereioredis
gets stuck with stale redis instances IPs and could not self-heal at all keeping the microservice that relies on it effectively broken until restart.Redis instances in the redis cluster setup may get restarted for various reasons like:
After that, redis instances end up having completely different IPs than the ones they had during
ioredis
initialization.ioredis
doesn't seem to update the redis cluster topology and in the severe cases when all redis instances got granularly updated, ioredis can fall into an infinite retry loop trying to establish connections with IPs that have already been removed from the system with the following types of messages:The
10.42.1.215
was one of the IPs thatioredis
reported as part of the cluster on initialization:After the pod had restarted the IP became stale.
Steps to Reproduce
That behavior can be reproduced by these steps:
Client Config
Here is how I have my
ioredis
cluster client configured:Is there a way to force ioredis to update its topology in such situation?
The text was updated successfully, but these errors were encountered: