Skip to content
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

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

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

barshaul
Copy link
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 merged commit 137c02e into valkey-io:release-1.2 Nov 12, 2024
8 checks passed
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