-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Master discovery frequency #3566
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
Comments
Hi @abdhx , apologies for the late response! I'll look at your question tomorrow. |
Hi @abdhx,
Let me know if you need further clarification! |
Hello @petyaslavova, I've conducted a test with a real failover scenario. During this test, I called Remarkably, after the failover, the Redis instance automatically rediscovered the master without requiring any custom cache code on my part. This auto reconnection behavior was not initially considered in my question, as I was unaware that the returned Redis object includes it. This behavior is cool and it's the solution to my issue, but is it intended? is it thread safe? I couldn't find this specifically outlined in the documentation. Thank you! ❤ |
Hi @abdhx, the discovery and establishment connection to the new master happen when we try to get a new connection from the connection pool - we have a validation that this connection is operational - in case of failover the connection we have is not operational and ConnectionError is raised (and catched) - in this case, we have a logic to disconnect the current connection and connect again - for sentinel client the connect process goes through discovering the current master and connecting to it. |
Thank you. |
Hello 👋,
I am using the Redis-py package to connect to a Redis cluster with Sentinel. I have a question about the best practice for discovering the master node.
Should I:
Use
sentinel.master_for
each time I execute a command to ensure I'm always talking to the current master?Discover the master once at startup and cache it, only re-discovering it periodically or upon errors? Do you have an example for this case?
Thank you for your help!
The text was updated successfully, but these errors were encountered: