fix(pruning): clear in-flight snapshot state when creation fails - #26787
Conversation
|
@greptile review |
Greptile SummaryThis PR replaces implicit snapshot-height bookkeeping with explicit start, completion, and failure transitions so failed snapshots no longer block pruning.
Confidence Score: 4/5The PR should preserve compatibility with SnapshotAnnouncer-only snapshotters before merging, because they currently lose the required start notification. The built-in root multi-store follows the new lifecycle correctly, but existing custom snapshotters implementing the retained announcement interface now receive only a post-success prune callback, breaking their established start-to-terminal callback sequence. Files Needing Attention: store/snapshots/manager.go, store/snapshots/types/snapshotter.go Important Files Changed
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26787 +/- ##
==========================================
+ Coverage 64.97% 65.30% +0.32%
==========================================
Files 785 830 +45
Lines 55413 58622 +3209
==========================================
+ Hits 36007 38282 +2275
- Misses 19406 20340 +934
🚀 New features to boost your workflow:
|
|
@songgaoye approved. please resolve conflicts |
|
@swift1337 please check again. Thanks! |
Summary
Fix pruning remaining blocked after snapshot creation fails.
The pruning manager previously inferred snapshot progress from announced and completed heights. When a snapshot failed after being announced, there was no failure transition to remove its height. The stale in-flight height could then cap pruning at
failedHeight - 1until the node restarted.This change replaces that implicit bookkeeping with an explicit snapshot lifecycle:
StartSnapshotrecords an in-flight snapshot.CompleteSnapshotremoves it and advances the durable completed checkpoint.FailSnapshotremoves it without advancing the checkpoint.Pruning is now bounded by the latest completed snapshot and the earliest snapshot still in flight. This correctly handles failures and out-of-order completion. For example, if snapshot 10 fails and snapshot 20 succeeds, pruning can advance using snapshot 20. If snapshot 10 is still running, pruning remains capped below 10 until it reaches a terminal state.
Only the completed checkpoint is persisted. In-flight state remains memory-only, and checkpoint persistence is performed atomically with the in-memory transition. Duplicate or stale completion calls are harmless and do not trigger unnecessary database writes.
This is a follow-up to #23638 and #24583. While #24583 improved pruning height calculation and restart handling, a failed snapshot could still remain tracked as in flight and block subsequent pruning.
Tests
Added coverage for snapshot lifecycle transitions, out-of-order completion, restart behavior, and persistence failures.
Closes: #XXXX