-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Watcher::send can deadlock #4246
Comments
Well, the watch channel is internally using an How could this happen? Well, the obvious way is if the same task calls That said, the above mistake is normally not possible to hit — the Does any of this ring a bell for your application? |
Hi @Darksonn, thank you for your support. |
I really don't see how |
I can try to. From reading #3661, is it possible that |
Well, it's not impossible that there's some problem in it, but the specific issue you have mentioned can only be related if its a livelock, and not a deadlock, and such a livelock would have to involve other threads calling |
That does seems unlikely. If relevant, we call |
Were you able to determine which line it gets stuck at? |
Apologies in advance for hijacking this issue. I landed here because I did myself find in the situation described by @Darksonn (#4246 (comment)), where holding the I find it a bit counter-intuitive that a sync primitive offered by I'm confident my use case is reasonable: I have the sender spawned into a separate Ideally I would recommend switching to a |
Yes, it's unfortunate that the watch channel can be used incorrectly in
That is not a supported use-case of the watch channel. If you need to block the value from changing, then you can't use a watch channel. Consider cloning the value instead so that you keep the old value even when a new one is sent. |
On the original issue, I haven't been able to gather more info, so feel free to close this as unactionable. |
Okay. I'll close this as unactionable. I opened #4741 for the warning about usage in non-Send code. |
Version
1.13, this also reproduced in earlier versions but 1.13 seemed to make it more frequent.
Platform
Debian buster-slim
Description
watch::Sender:::send
can deadlock. Unfourtunately I do not have a reproduction case as I've only observed it in our production environment, where there are hundreds of receivers for the watcher, and the system is generally under a heavy load in terms of number of tasks and overall number of threads. It deadlocks only after the system has been running for a few hours, so it must be some form of timing condition. But I know for sure that it is deadlocking because a log was inserted immediately before and immediately after the call tosend
, and the log after is never printed while all other tasks continue to make progress. The only related report I could find in this repo is #3661. Perhaps relevant is that the tasks woken up by the watcher may clone the receiver of that same watcher and callReceiver::changed
on it.The text was updated successfully, but these errors were encountered: