-
Notifications
You must be signed in to change notification settings - Fork 2.7k
SentinelConnectionPool should retrieve updated master address from Sentinel on connection retries #3875
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
base: master
Are you sure you want to change the base?
SentinelConnectionPool should retrieve updated master address from Sentinel on connection retries #3875
Changes from 6 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,29 +37,19 @@ def __repr__(self): | |||||
| s = s % host_info | ||||||
| return s | ||||||
|
|
||||||
| def connect_to(self, address): | ||||||
| self.host, self.port = address | ||||||
|
|
||||||
| self.connect_check_health( | ||||||
| check_health=self.connection_pool.check_connection, | ||||||
| retry_socket_connect=False, | ||||||
| ) | ||||||
|
|
||||||
| def _connect_retry(self): | ||||||
| def _connect(self): | ||||||
| if self._sock: | ||||||
| return # already connected | ||||||
| return super()._connect() # already connected | ||||||
|
||||||
| return super()._connect() # already connected | |
| return # already connected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the connection is already established, _connect is never called https://github.com/redis/redis-py/blob/v7.1.0/redis/connection.py#L852
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here is incorrect. When
self.is_connectedis True, the connection is already established and the method should simply return without callingsuper()._connect(). The check should just return early:Calling
await super()._connect()when already connected could cause issues as it attempts to setself._readerandself._writeragain.