Skip to content

[release-3.7] fix: fsync snap directory when saving a received snapshot db - #22378

Open
k8s-infra-cherrypick-robot wants to merge 2 commits into
etcd-io:release-3.7from
k8s-infra-cherrypick-robot:cherry-pick-22314-to-release-3.7
Open

[release-3.7] fix: fsync snap directory when saving a received snapshot db#22378
k8s-infra-cherrypick-robot wants to merge 2 commits into
etcd-io:release-3.7from
k8s-infra-cherrypick-robot:cherry-pick-22314-to-release-3.7

Conversation

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

This is an automated cherry-pick of #22314

/assign fuweid

SaveDBFrom synced a received snapshot database before renaming it into place, but did not sync the containing directory. Linux fsync(2) documents that syncing a file does not necessarily persist its directory entry; the directory must also be synced.

The snapshot receiver calls SaveDBFrom before processing the Raft message, which can later sync the WAL snapshot record. Sync the snapshot directory after rename and on the existing-file retry path, and return sync errors so snapshot handling stops before Raft processing.

Add direct unit coverage that both SaveDBFrom paths invoke directory sync and propagate failures. Keep gofail E2E coverage scoped to failure/retry and crash-before-return control flow; remove tests and claims that did not establish directory-entry durability.

Signed-off-by: Gyuho Lee <gyuhol@nvidia.com>
Signed-off-by: Gyuho Lee <gyuhol@nvidia.com>
@kubernetes-prow

Copy link
Copy Markdown

Hi @k8s-infra-cherrypick-robot. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@gyuho

gyuho commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

/approve

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gyuho, k8s-infra-cherrypick-robot
Once this PR has been reviewed and has the lgtm label, please ask for approval from fuweid. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.82%. Comparing base (df66450) to head (d9d66ca).

Files with missing lines Patch % Lines
server/etcdserver/api/snap/db.go 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
server/etcdserver/api/snap/snapshotter.go 69.86% <100.00%> (+1.58%) ⬆️
server/etcdserver/api/snap/db.go 70.96% <86.66%> (+9.26%) ⬆️

... and 16 files with indirect coverage changes

@@               Coverage Diff               @@
##           release-3.7   #22378      +/-   ##
===============================================
+ Coverage        69.74%   69.82%   +0.07%     
===============================================
  Files              449      449              
  Lines            38215    38231      +16     
===============================================
+ Hits             26652    26693      +41     
+ Misses           10132    10113      -19     
+ Partials          1431     1425       -6     

Continue to review full report in Codecov by Harness.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fuweid

fuweid commented Sep 4, 2026

Copy link
Copy Markdown
Member

/retest

@kubernetes-prow

kubernetes-prow Bot commented Sep 4, 2026

Copy link
Copy Markdown

@k8s-infra-cherrypick-robot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-grpcproxy-e2e-amd64 d9d66ca link true /test pull-etcd-grpcproxy-e2e-amd64
pull-etcd-e2e-arm64 d9d66ca link true /test pull-etcd-e2e-arm64

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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.

3 participants