Skip to content

Commit c878e3b

Browse files
committed
Log deleted snapshots
1 parent 91002cb commit c878e3b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cardano-db-sync/src/Cardano/DbSync/Ledger/Snapshot.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ findStateFromSnapshot env point = do
169169
Right sr -> pure $ Right sr
170170
Left err -> do
171171
logWarning (leTrace env) $ "Failed to load snapshot: " <> err <> ". Trying older."
172+
logInfo (leTrace env) $ "Deleting failed snapshot: " <> textShow (snapshotToDirName ds)
172173
safeDeleteSnapshot (leSnapshotManager env) ds
173174
let older = List.filter (\d -> SlotNo (dsNumber d) < targetSlot) rest
174175
pure $ Left older
@@ -197,11 +198,15 @@ deleteNewerSnapshots env point = do
197198
snapshots <- listDiskSnapshots env
198199
case getPoint point of
199200
Origin ->
200-
forM_ snapshots $ safeDeleteSnapshot (leSnapshotManager env)
201+
forM_ snapshots $ \ds -> do
202+
logInfo (leTrace env) $ "Deleting snapshot (replaying from genesis): " <> textShow (snapshotToDirName ds)
203+
safeDeleteSnapshot (leSnapshotManager env) ds
201204
At blk -> do
202205
let targetSlot = Point.blockPointSlot blk
203206
newer = filter (\ds -> SlotNo (dsNumber ds) > targetSlot) snapshots
204-
forM_ newer $ safeDeleteSnapshot (leSnapshotManager env)
207+
forM_ newer $ \ds -> do
208+
logInfo (leTrace env) $ "Deleting newer snapshot: " <> textShow (snapshotToDirName ds)
209+
safeDeleteSnapshot (leSnapshotManager env) ds
205210

206211
-- | List known snapshot points (both in-memory and on-disk).
207212
listKnownSnapshots :: HasLedgerEnv -> IO [SnapshotPoint]

0 commit comments

Comments
 (0)