snap: keep snapshot db files until they have been applied#22046
snap: keep snapshot db files until they have been applied#22046darshil929 wants to merge 1 commit into
Conversation
Signed-off-by: darshil929 <darshilt.work29@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: darshil929 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
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