Skip to content

Hitless upgrade support implementation for synchronous Redis client. #3713

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

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

petyaslavova
Copy link
Collaborator

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)?

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

Description of change

Hitless upgrade support implementation for synchronous Redis client.

Copilot

This comment was marked as outdated.

@petyaslavova petyaslavova force-pushed the ps_hitless_upgrade_sync_redis branch 4 times, most recently from 0304da5 to ee27bd2 Compare July 22, 2025 16:51
@petyaslavova petyaslavova force-pushed the ps_hitless_upgrade_sync_redis branch from ee27bd2 to 0f9734c Compare July 24, 2025 13:43
@petyaslavova petyaslavova force-pushed the ps_hitless_upgrade_sync_redis branch from 0f9734c to 6d496f0 Compare July 24, 2025 13:45
@petyaslavova petyaslavova requested a review from Copilot July 26, 2025 10:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements hitless upgrade support for the synchronous Redis client by introducing maintenance event handling capabilities. This feature allows Redis clients to gracefully handle cluster maintenance operations like node migrations and replacements without dropping connections or failing commands.

Key changes include:

  • Added comprehensive maintenance events framework with event classes and handlers
  • Extended connection pool to support maintenance states and temporary configurations
  • Integrated push notification handlers for RESP3 protocol maintenance events

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/test_maintenance_events_handling.py Comprehensive integration tests for maintenance events handling with mock sockets
tests/test_maintenance_events.py Unit tests for maintenance event classes, configurations, and handlers
tests/test_connection_pool.py Added should_reconnect method to test connection mock
redis/maintenance_events.py Core maintenance events framework with event classes, configurations, and handlers
redis/connection.py Enhanced connection and pool classes with maintenance event support and state management
redis/client.py Integrated maintenance events configuration into Redis client initialization
redis/asyncio/connection.py Added maintenance mode support for async blocking connection pool
redis/_parsers/resp3.py Enhanced RESP3 parser with push notification handlers for maintenance events
redis/_parsers/hiredis.py Added maintenance event push handlers to hiredis parser
redis/_parsers/base.py Added maintenance event parsing logic and handler registration methods

)
if getattr(self.pool, "set_in_maintenance", False):
self.pool.set_in_maintenance(False)
print(f"Starting timer for {event} for {event.ttl} seconds")
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Remove debug print statement from production code. Use logging instead if debug output is needed.

Suggested change
print(f"Starting timer for {event} for {event.ttl} seconds")
logging.info(f"Starting timer for {event} for {event.ttl} seconds")

Copilot uses AI. Check for mistakes.

def validate_free_connections_state(
pool,
should_be_connected_count=0,
connected_to_tmp_addres=False,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=False,
connected_to_tmp_address=False,

Copilot uses AI. Check for mistakes.

expected_orig_socket_timeout=None,
expected_orig_socket_connect_timeout=None,
should_be_connected_count=1,
connected_to_tmp_addres=True,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=True,
connected_to_tmp_address=True,

Copilot uses AI. Check for mistakes.

expected_orig_socket_timeout=None,
expected_orig_socket_connect_timeout=None,
should_be_connected_count=1,
connected_to_tmp_addres=True,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=True,
connected_to_tmp_address=True,

Copilot uses AI. Check for mistakes.

Helpers.validate_free_connections_state(
pool=test_redis_client.connection_pool,
should_be_connected_count=1,
connected_to_tmp_addres=True,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=True,
connected_to_tmp_address=True,

Copilot uses AI. Check for mistakes.

Helpers.validate_free_connections_state(
test_redis_client.connection_pool,
should_be_connected_count=1,
connected_to_tmp_addres=True,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=True,
connected_to_tmp_address=True,

Copilot uses AI. Check for mistakes.

Helpers.validate_free_connections_state(
pool=pool,
should_be_connected_count=0,
connected_to_tmp_addres=False,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=False,
connected_to_tmp_address=False,

Copilot uses AI. Check for mistakes.

Helpers.validate_free_connections_state(
pool=pool,
should_be_connected_count=0,
connected_to_tmp_addres=False,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.

Suggested change
connected_to_tmp_addres=False,
connected_to_tmp_address=False,

Copilot uses AI. Check for mistakes.


def set_tmp_settings(
self,
tmp_host_address: Optional[Union[str, object]] = SENTINEL,
Copy link
Preview

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

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

Using SENTINEL as a default value but SENTINEL is not defined in this scope. This could cause a NameError.

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

2 participants