Skip to content

Core: Release the read lock while creating connections in refresh_connections#2630

Merged
barshaul merged 1 commit intovalkey-io:release-1.2from
barshaul:dont_lock_on_reconnect
Nov 12, 2024
Merged

Core: Release the read lock while creating connections in refresh_connections#2630
barshaul merged 1 commit intovalkey-io:release-1.2from
barshaul:dont_lock_on_reconnect

Conversation

@barshaul
Copy link
Copy Markdown
Collaborator

@barshaul barshaul commented Nov 6, 2024

Lock Management Improvement:

In the previous implementation, the read lock (inner.conn_lock.read()) was held throughout the entire connection refresh process (for all connections sent to refresh), including while attempting to establish connections (via get_or_create_conn). If connections were slow or timed out, the lock was held for an extended duration, blocking other tasks requiring a write lock.

The new implementation releases the read lock before making connection attempts. If the connection is successfully established, the read lock is reacquired to update the connection container. This approach ensures that other operations needing the lock (e.g., write operations) can proceed while connections are being established.

This commit was already approved on our redis-rs fork but wasn't merged into glide, see former PR amazon-contributing/redis-rs#191.

@barshaul barshaul force-pushed the dont_lock_on_reconnect branch 2 times, most recently from 59386d8 to cb1f91a Compare November 6, 2024 15:37
@barshaul barshaul marked this pull request as ready for review November 6, 2024 15:38
@barshaul barshaul requested a review from a team as a code owner November 6, 2024 15:38
@barshaul barshaul requested a review from eifrah-aws November 6, 2024 15:39
…ections

Signed-off-by: barshaul <barshaul@amazon.com>
@barshaul barshaul force-pushed the dont_lock_on_reconnect branch from c9b3a5b to 256f6d8 Compare November 12, 2024 14:03
@barshaul barshaul merged commit 137c02e into valkey-io:release-1.2 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants