-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Prevent leaking file descriptor during snapshotting and provide better logging of errors #19093
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
... and 44 files with indirect coverage changes @@ Coverage Diff @@
## main #19093 +/- ##
==========================================
- Coverage 68.85% 68.79% -0.07%
==========================================
Files 420 420
Lines 35642 35650 +8
==========================================
- Hits 24541 24525 -16
- Misses 9676 9704 +28
+ Partials 1425 1421 -4 Continue to review full report in Codecov by Sentry.
|
b3a68b9
to
a1d5008
Compare
We need to close all previous similar PRs, one of which is #18200 |
if err != nil { | ||
return "", fmt.Errorf("could not open %s (%w)", partpath, err) | ||
} | ||
defer func() { | ||
err = f.Close() | ||
if err != nil && !errors.Is(err, os.ErrClosed) { |
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.
It works. But I think a better and more explicit way is to use sync.Once
to ensure f.Close is only executed once. So that it's well aware that we need to close the file before renaming, but also need to ensure it's closed in case early return due to any error.
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.
Checked https://pkg.go.dev/os#File.Close and the api can guarantee it can be executed only once. sync.Once
is not neccesary here.
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.
Not a big deal, please feel free to merge this PR and backport to 3.5 and 3.4.
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.
SGTM
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.
LGTM
/retest |
…r logging of errors Signed-off-by: Marek Siarkowicz <[email protected]>
a1d5008
to
c504fed
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, fuweid, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
cc @ahrtr @fuweid @ivanvc
Found case where a leaked file descriptor prevents data being deleted from disk and filling up the disk.
Would like to backport it to all v3.5 and v3.4