Skip to content

Conversation

@serathius
Copy link
Member

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

@codecov
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 45.00000% with 11 lines in your changes missing coverage. Please review.

Project coverage is 68.79%. Comparing base (9fa35e5) to head (c504fed).
Report is 94 commits behind head on main.

Files with missing lines Patch % Lines
client/v3/snapshot/v3_snapshot.go 45.00% 7 Missing and 4 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
client/v3/snapshot/v3_snapshot.go 52.72% <45.00%> (-5.42%) ⬇️

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

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9fa35e5...c504fed. Read the comment docs.

@ahrtr
Copy link
Member

ahrtr commented Dec 20, 2024

We need to close all previous similar PRs, one of which is #18200

}
defer func() {
err = f.Close()
if err != nil && !errors.Is(err, os.ErrClosed) {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jmhbnz
Copy link
Member

jmhbnz commented Jan 16, 2025

/retest

@k8s-ci-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@serathius
Copy link
Member Author

/retest

@serathius serathius merged commit 5d47d7f into etcd-io:main Jan 17, 2025
34 checks passed
@ivanvc ivanvc mentioned this pull request May 28, 2025
4 tasks
@ivanvc ivanvc mentioned this pull request Jul 6, 2025
2 tasks
@ahrtr ahrtr mentioned this pull request Nov 5, 2025
4 tasks
@ahrtr
Copy link
Member

ahrtr commented Nov 5, 2025

The PR fixed #18085

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

Development

Successfully merging this pull request may close these issues.

5 participants