Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

<!--
### Patch
- A bullet item for the Patch category.
-->
<!--
### Non-Breaking
- A bullet item for the Non-Breaking category.
-->
### Breaking

- Legacy snapshots will be rejected and deleted, instead of crashing consensus.
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,10 @@ loadSnapshot ::
Session m ->
DiskSnapshot ->
ExceptT (SnapshotFailure blk) m (LedgerSeq' m blk, RealPoint blk)
loadSnapshot tracer rr ccfg fs session ds =
loadSnapshot tracer rr ccfg fs@(SomeHasFS hfs) session ds =
do
fileEx <- lift $ doesFileExist hfs (snapshotToDirPath ds)
Monad.when fileEx $ throwE $ InitFailureRead ReadSnapshotIsLegacy
snapshotMeta <-
withExceptT (InitFailureRead . ReadMetadataError (snapshotToMetadataPath ds)) $
loadSnapshotMetadata fs ds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,10 @@ initialize
traceWith snapTracer $ InvalidSnapshot s err
tryNewestFirst (acc . InitFailure s err) ss

-- If the snapshot has a checksum that doesn't match the actual data,
-- issue a warning, delete it, and try the next oldest snapshot
Left err@(InitFailureRead ReadSnapshotDataCorruption) -> do
-- If it is a legacy snapshot, issue a warning and try
-- the next oldest snapshot
Left err@(InitFailureRead ReadSnapshotIsLegacy) -> do
traceWith snapTracer $ InvalidSnapshot s err
Monad.when (diskSnapshotIsTemporary s) $ do
traceWith snapTracer $ DeletedSnapshot s
deleteSnapshot snapManager s
tryNewestFirst (acc . InitFailure s err) ss

-- If we fail to use this snapshot for any other reason, delete it and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ data ReadSnapshotErr
ReadSnapshotDataCorruption
| -- | An error occurred while reading the snapshot metadata file
ReadMetadataError FsPath MetadataErr
| -- | We were given a legacy snapshot
ReadSnapshotIsLegacy
deriving (Eq, Show)

data TablesCodecVersion = TablesCodecVersion1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ import Ouroboros.Consensus.Util.Args (Complete)
import Ouroboros.Consensus.Util.Enclose
import Ouroboros.Consensus.Util.IOLike
import System.FS.API
import qualified System.FS.API as FS

snapshotManager ::
( IOLike m
Expand Down Expand Up @@ -293,7 +294,9 @@ loadSnapshot ::
(SnapshotFailure blk)
m
((DbChangelog' blk, ResourceKey m, LedgerBackingStore m (ExtLedgerState blk)), RealPoint blk)
loadSnapshot tracer bArgs@(SomeBackendArgs bss) ccfg fs@(SnapshotsFS fs') reg s = do
loadSnapshot tracer bArgs@(SomeBackendArgs bss) ccfg fs@(SnapshotsFS fs'@(SomeHasFS hfs)) reg s = do
fileEx <- Trans.lift $ FS.doesFileExist hfs (snapshotToDirPath s)
Monad.when fileEx $ throwError $ InitFailureRead ReadSnapshotIsLegacy
(extLedgerSt, checksumAsRead) <-
withExceptT (InitFailureRead . ReadSnapshotFailed) $
readExtLedgerState fs' (decodeDiskExtLedgerState ccfg) decode (snapshotToStatePath s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ loadSnapshot ::
SomeHasFS m ->
DiskSnapshot ->
ExceptT (SnapshotFailure blk) m (LedgerSeq' m blk, RealPoint blk)
loadSnapshot tracer _rr ccfg fs ds = do
loadSnapshot tracer _rr ccfg fs@(SomeHasFS hfs) ds = do
fileEx <- lift $ doesFileExist hfs (snapshotToDirPath ds)
Monad.when fileEx $ throwE $ InitFailureRead ReadSnapshotIsLegacy

snapshotMeta <-
withExceptT (InitFailureRead . ReadMetadataError (snapshotToMetadataPath ds)) $
loadSnapshotMetadata fs ds
Expand Down
Loading