-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: master
Are you sure you want to change the base?
Conversation
0304da5
to
ee27bd2
Compare
… tests for maintenance_events.py file
…tion pool - this should be a separate PR
… Refactored the maintenance events tests not to be multithreaded - we don't need it for those tests.
…ot processed in in Moving state. Tests are updated
…ply them during connect
ee27bd2
to
0f9734c
Compare
0f9734c
to
6d496f0
Compare
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.
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") |
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.
Remove debug print statement from production code. Use logging instead if debug output is needed.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
Fix typo in parameter name: 'connected_to_tmp_addres' should be 'connected_to_tmp_address'.
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, |
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.
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.
Pull Request check-list
Please make sure to review and check all of these items:
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.