-
Notifications
You must be signed in to change notification settings - Fork 440
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
Handle write edge case when first write is out of order write #2929
base: master
Are you sure you want to change the base?
Conversation
…d by write at offset 0
internal/fs/inode/file.go
Outdated
err := f.ensureBufferedWriteHandler(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if f.bwh != nil { | ||
return f.writeUsingBufferedWrites(ctx, data, offset) | ||
if f.bwh != nil && !isTempFileInUse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need isTempFileInUse check here. Do you any scenario where bwh != nil but we need to use disk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was not required, thanks! ensured that we never create bwh when temp file is in use (truncate was the other such scenario).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2929 +/- ##
==========================================
+ Coverage 75.66% 75.68% +0.02%
==========================================
Files 125 125
Lines 17641 17660 +19
==========================================
+ Hits 13348 13366 +18
Misses 3732 3732
- Partials 561 562 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Description
Handle write edge case when first write is out of order write followed by write at offset 0.
Issue: when we get out of order write, we flush buffered write handler (to finalize whatever we have) and also set bwh to nil
First out of order write creates a source object of size 0, so even after bwh is cleared, it is recreated during the write call. Later when a write at offset 0 happens, it will go to bwh. Partial writes to bwh and temp file can cause errors.
Solution: If temp file is in use, don't re-create buffered write handler.
Link to the internal issue
b/391545203
Testing details