Skip to content

Add Redis readiness verification (#3555) #3596

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 #3555 (specially the comment on that issue)

Please check if you'd rather run the tests with check_ready=True by default (I also tested that) and if you think that any other tests deserve a second version with this flag set.

@petyaslavova
Copy link
Collaborator

Hi @ManelCoutinhoSensei, thank you for your contribution! We’ll review your change soon.

@ManelCoutinhoSensei
Copy link
Author

@petyaslavova you need to rerun the failed tests due to the test suit flakiness

@ManelCoutinhoSensei
Copy link
Author

Hi @petyaslavova , any news about this one?

@petyaslavova
Copy link
Collaborator

Hi @ManelCoutinhoSensei, I have started the review, but couldn't complete it.
We have some urgent changes we need to complete, and the PR reviews will be delayed by a week or two.
Sorry for the delay!

@ManelCoutinhoSensei
Copy link
Author

Should I solve the conflicts because the PR reviews are going to be done this week or should I postpone it?

@petyaslavova
Copy link
Collaborator

Should I solve the conflicts because the PR reviews are going to be done this week or should I postpone it?

Hi @ManelCoutinhoSensei, please wait for a while with the conflict solving. We first need to address one more planned change related to the async cluster, and then I will be able to progress on this PR.
Thank you for your patience and understanding!

@ManelCoutinhoSensei
Copy link
Author

Hey @petyaslavova! 🙌 Just checking in to see if there are any updates or an estimated timeline for moving forward with this PR. Totally understand things can get busy — just wanted to make sure it’s still on your radar.
Thanks again for your time and support! 😊

@ManelCoutinhoSensei
Copy link
Author

cyring-in-the-rain

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 delay in reviewing the PR. I've added some comments and suggestions for changes that I believe will help make the code more maintainable in the long term. While the comments are placed in the sync client/connection code, they apply to the async parts as well.

@@ -933,7 +968,6 @@ async def _connect(self):
reader, writer = await asyncio.open_unix_connection(path=self.path)
self._reader = reader
self._writer = writer
await self.on_connect()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you remove this call?

# Doing handshake since connect and send operations work even when Redis is not ready
if self.check_ready:
try:
ping_parts = self._command_packer.pack("PING")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to replace this block with a call to self._send_ping(), and refactor that method to accept an additional argument—something like accept_no_auth_response=False by default. This way, you can reuse the existing logic without duplicating the socket write/read operations, making the code cleaner and easier to maintain.

@@ -203,6 +203,7 @@ def __init__(
encoding: str = "utf-8",
encoding_errors: str = "strict",
decode_responses: bool = False,
check_ready: bool = False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add details about this setting to the pydocs. Also, I would suggest changing the name so that it would be easier to understand its purpose just by looking at the name, something like check_server_ready, or on_connect_check_server_ready

@@ -378,12 +380,35 @@ def connect(self):
"Connects to the Redis server if not already connected"
self.connect_check_health(check_health=True)

def _connect_check_ready(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this method after connect_check_health

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.

Retry Mechanism Fails When Redis Container is Paused
2 participants