Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ashmeenkaur
Copy link
Collaborator

@ashmeenkaur ashmeenkaur commented Jan 22, 2025

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

  1. Manual - NA
  2. Unit tests - added
  3. Integration tests - NA

@ashmeenkaur ashmeenkaur changed the title handle write edge case when first write is out of order write Handle write edge case when first write is out of order write Jan 22, 2025
@ashmeenkaur ashmeenkaur marked this pull request as ready for review January 22, 2025 11:34
@ashmeenkaur ashmeenkaur requested a review from a team as a code owner January 22, 2025 11:34
@kislaykishore kislaykishore requested a review from a team January 22, 2025 11:35
@ashmeenkaur ashmeenkaur requested review from meet2mky and vadlakondaswetha and removed request for kislaykishore January 22, 2025 11:36
err := f.ensureBufferedWriteHandler(ctx)
if err != nil {
return err
}
}

if f.bwh != nil {
return f.writeUsingBufferedWrites(ctx, data, offset)
if f.bwh != nil && !isTempFileInUse {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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).

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 62.50000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 75.68%. Comparing base (cdadf09) to head (ab1951b).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
internal/fs/inode/file.go 62.50% 6 Missing and 3 partials ⚠️
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     
Flag Coverage Δ
unittests 75.68% <62.50%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants