-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Clone may "miss" ongoing operations #5759
Comments
Seems reasonable enough to me. |
@Darksonn which part seems reasonable? The bug, the fix, or the documentation? If the third, I can make a PR :) |
Waiting until pending operations have finished sounds good to me. |
I'm less confident I can accomplish that, but I will give it a shot :) |
You can just call |
I got a start in https://github.com/tokio-rs/tokio/compare/master...djmitche:tokio:issue5759?expand=1. I think the fix is straightforward, although it requires Do you mind assigning this issue to me so it shows in my dashboard? |
Ah, we don't want it to take |
At least on Linux, you can probably test this using a pipe. That will let you create a |
Ah, As for testing: the bug occurs when an operation is incomplete on the original File, because its To demonstrate the error in a test, I'd need to make the operation block. I could use a pipe to do so, by calling I think I've convinced myself that there's no way to test reliably -- the best I can do is a test that, without the fix, fails intermittently. So I'll work on that. |
Flushing just calls |
If there is an ongoing operation on a file, wait for that to complete before performing the clone in `File::try_clone`. This avoids a race between the ongoing operation and any subsequent operations performed on the clone. Fixes: tokio-rs#5759
Version
Platform
Linux
Description
The following will fail intermittently (a simplification of taskcluster/taskcluster#6280). It fails particularly under high CPU load.
What's happening is that the
write_all
is starting a write operation in another thread, and returning Poll::Ready. Thetry_clone
, however, misses that there's an operation ongoing and creates a new File with no such operation. So there's a race between thatwrite
completing in another thread and theread
performed bycopy
.I would expect the
try_clone
to wait until any operations that have already been described as complete actually are complete. I can see that being hard to implement, though. Perhaps the documentation could be updated with something likeThis is similar to #4796. I couldn't find how that issue was fixed (no commits around June 30, 2022 seemed relevant), but the current documentation doesn't describe this situation (at least not in a way that's clear to me even after having found the problem).
The text was updated successfully, but these errors were encountered: