Skip to content

snap: keep snapshot db files until they have been applied#22046

Open
darshil929 wants to merge 1 commit into
etcd-io:mainfrom
darshil929:fix/18055-keep-pending-snapshot-dbs
Open

snap: keep snapshot db files until they have been applied#22046
darshil929 wants to merge 1 commit into
etcd-io:mainfrom
darshil929:fix/18055-keep-pending-snapshot-dbs

Conversation

@darshil929

Copy link
Copy Markdown

When a follower receives two snapshots in a short period, the raft loop persisting the newer one releases all older snapshot database files, while the apply loop may still be waiting to apply an older snapshot. Its .snap.db file gets deleted while the apply is pending, and when applySnapshot opens it through OpenSnapshotBackend the server panics with "failed to open snapshot backend". This has been hit in robustness testing CI and reproduced by Antithesis on default configuration.

The Snapshotter now tracks snapshot database files that are pending apply: SaveDBFrom marks the index on save, ReleaseSnapDBs skips marked files, and OpenSnapshotBackend drops the mark once the rename consumes the file. The tracking is in memory only, so stale files from a previous run are still cleaned up at boot, same as before.

Added a test reproducing the sequence: save the db file for snapshot A, run ReleaseSnapDBs for a newer snapshot B, then look up A's file as the apply path does. It fails on main with "snap: snapshot file doesn't exist", the exact error behind the panic, and passes with the change. The test also verifies the file becomes eligible for cleanup again once the apply completes.

Fixes #18055

Signed-off-by: darshil929 <darshilt.work29@gmail.com>
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: darshil929
Once this PR has been reviewed and has the lgtm label, please assign jmhbnz for approval. 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

@kubernetes-prow

Copy link
Copy Markdown

Hi @darshil929. 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.

Regular contributors should join the org to skip this step.

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.

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.

panic when two snapshots are received in short period

1 participant