Skip to content

feat: add lock for hooks.dial #2460

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 1 commit into
base: master
Choose a base branch
from

Conversation

monkey92t
Copy link
Collaborator

@monkey92t monkey92t commented Feb 26, 2023

See #2453

We added a lock to DialHook, but ProcessHook, ProcessPipelineHook are still not thread-safe.

If the Options.MinIdleConns parameter is set, go-redis will create a network connection asynchronously, and there may be a data race (hooks.dial) with the AddHook() API, and even a part of the network connection is created before the AddHook operation.

We only need to pay for the overhead of the read lock for the DialHook.

Signed-off-by: monkey92t <golang@88.com>
@vmihailenco
Copy link
Collaborator

I've tried to review you this, but the existing code looks confusing enough and locking does not make it better :( I will try to get back to this later and make API cleaner and more understandable...

@monkey92t
Copy link
Collaborator Author

I've tried to review you this, but the existing code looks confusing enough and locking does not make it better :( I will try to get back to this later and make API cleaner and more understandable...

Yes...Indeed, we introduced more complex code to solve a problem, and in my view, DialHook and MinIdleConns are conflicting.

@zcong1993
Copy link

Any updates?

@zcong1993
Copy link

ping

@bramsvs
Copy link

bramsvs commented Jul 18, 2023

@vmihailenco any updates on this? :)

@duongcongtoai
Copy link

ping

@ndyakov
Copy link
Member

ndyakov commented May 7, 2025

@monkey92t would you like to revisit this after #3320 ?

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.

7 participants