Skip to content

timeout instead of race to fix async wait time #222

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

g-divyanshu
Copy link

@g-divyanshu g-divyanshu commented Feb 25, 2024

Problem Statement: In an application deployed in my organisation, we were seeing an increased time to connect to redis, when we increased the value of connectTimeout.

Reason: This was happening because of the higher timeout value which was being passed to race in connect function as timeoutOpt. Function race internally calls cancel and cancel will not terminate until the thread that Async refers to has been terminated.

Solution : Used timeout function instead of race to handle that scenario and now it works fine.

arybczak added a commit to scrive/hedis that referenced this pull request Apr 25, 2025
The former works reliably, whether the latter doesn't. Case in point:

```
uninterruptibleMask_ $ race (putStrLn "Hi") (threadDelay 1000000)
```

will wait a second even though the first operation finishes immediately.

See informatikr#222 - I couldn't reproduce this
behaviour locally, but we might be also hitting this problem for some reason.
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