-
-
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
fs: Data loss while retrying File::flush
when disk is full
#6325
Comments
I'm a bit confused. I'm less familiar w/ the details of FS ops.
The key problem w/ Tokio's impl or getting an err when calling flush in general? Maybe you could explain how to handle |
I believe it's more like an issue of Tokio's implementation, which doesn't pass the write error on to the user.
There is no direct mapping from I prepared a full repro here: https://github.com/Xuanwo/tokio-issue-6325-storage-full let n = f.write(&bs).await?;
dbg!(&n);
assert_eq!(n, size, "tokio file always write data into buffer first"); While we calling The same repro doesn't work on |
Fixes: tokio-rs#6325 Signed-off-by: Xuanwo <github@xuanwo.io>
Fixes: tokio-rs#6325 Signed-off-by: Xuanwo <github@xuanwo.io>
During implement #6330, I found that tokio will clear the buffer while error happened during write. tokio/tokio/src/io/blocking.rs Lines 258 to 265 in 28d88cc
I'm guessing we need to maintain the internal states here instead of droping all data? |
Version
Platform
Linux xuanwo-work 6.7.3-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Thu, 01 Feb 2024 10:30:25 +0000 x86_64 GNU/Linux
Description
While addressing apache/opendal#4058, we discovered that retrying
File::flush
while disk is full could result in data loss.To reproduce:
Now we have a fs that only have 512K.
The full code example code be found at apache/opendal#4141. I remove the opendal related code to make this example more readable.
The output is:
The first time,
flush
generatesStorageFull
which is expeceted. But the second time, the same flush call returnsOk
.I expected to see a
StorageFull
error instead.The key problem here is:
Ok
.Ok
.Based on the code here:
tokio/tokio/src/fs/file.rs
Lines 887 to 906 in 63caced
Maybe we should:
buf
?last_write_err
if the write operation failed?I'm willing to give it a fix.
The text was updated successfully, but these errors were encountered: