Skip to content

SentinelManagedConnection searches for new master upon connection failure (#3560) #3601

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ManelCoutinhoSensei
Copy link

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Fixes #3560. It should be reviewed after merging #3596

@petyaslavova
Copy link
Collaborator

Hi @ManelCoutinhoSensei, thank you for your contribution! We’ll review your change soon(after PR #3596 :) ).

@ManelCoutinhoSensei
Copy link
Author

It's been 2 months... do you have any updates @petyaslavova ?

Copy link
Collaborator

@petyaslavova petyaslavova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ManelCoutinhoSensei,
Apologies for the late response. I’ve reviewed the code and added a few comments.

@@ -294,13 +328,16 @@ def discover_master(self, service_name):
"""
collected_errors = list()
for sentinel_no, sentinel in enumerate(self.sentinels):
# print(f"Sentinel: {sentinel_no}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented print statements should be removed.

if str_if_bytes(await self.read_response()) != "PONG":
raise ConnectionError("PING failed")

if self.is_connected:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s quite a bit of code duplication. Perhaps the approach with a flag would be preferable after all. Since connect() is part of the interface, I think it’s better not to modify it directly. Instead, you can use the connect_with_health_check() method from AbstractConnection. You could introduce an additional flag to enable or disable retry_socket_connect, with a default value that preserves the current behaviour.

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

Successfully merging this pull request may close these issues.

SentinelManagedConnection delays new master detection and Risks data loss
2 participants