Skip to content
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

Why connection not close when the response is "READONLY error" #790

Closed
todywu opened this issue Jun 15, 2018 · 4 comments
Closed

Why connection not close when the response is "READONLY error" #790

todywu opened this issue Jun 15, 2018 · 4 comments

Comments

@todywu
Copy link

todywu commented Jun 15, 2018

Issue
Firstly I have connected to master redis server and every write operation is OK, but after about one hour, the master and slave redis role interchanged. The write operation on connection with previous master will return "READONLY error" but the connection is not closed and the error is continue. Can we close the connection after receive an error from redis server?

@todywu todywu changed the title Why connecttion not close when the response is "READONLY error" Why connection not close when the response is "READONLY error" Jun 15, 2018
@vmihailenco
Copy link
Collaborator

Do you use Redis Cluster or Redis Sentinel?

@todywu
Copy link
Author

todywu commented Jun 15, 2018

Thank you for the answer. I am not use Redis Cluster and Redis Sentinel. There are two redis server in my product environment, one is master and another is slave. The redis client use NewClient() to get a client instance and Addr is redis domain name. When redis server role is interchanged, the redis domain name will be mapped to the new master server. New connection will connect to this new master server and wirte operation is OK, but the old connection is response "READONLY error" contineouly.

@vmihailenco
Copy link
Collaborator

So to answer your question - "READONLY error" connections are not closed, because Client, ClusterClient, FailoverClient, and Ring does not require it and such connection is perfectly healthy - it is just read-only.

That said your use case makes sense and closing connections on read-only errors is probably fine and should not affect existing code.

@todywu
Copy link
Author

todywu commented Jun 19, 2018

I am certainly seeing your commit and thank you very much for reslove this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants