Skip to content

Commit 3a026c7

Browse files
committed
Fix tracing messages for Snapshot checksum errors
1 parent 43f4c38 commit 3a026c7

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal (chunkN
3535
import qualified Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types as ImmDB
3636
import Ouroboros.Consensus.Storage.LedgerDB (ReplayStart (..),
3737
UpdateLedgerDbTraceEvent (..))
38+
import qualified Ouroboros.Consensus.Storage.LedgerDB.Snapshots as LedgerDB
3839
import qualified Ouroboros.Consensus.Storage.LedgerDB as LedgerDB
3940
import qualified Ouroboros.Consensus.Storage.VolatileDB as VolDB
4041
import Ouroboros.Consensus.Util.Condense (condense)
@@ -1566,12 +1567,19 @@ instance ( StandardHash blk
15661567
]
15671568
where
15681569
context = case failure of
1569-
LedgerDB.InitFailureRead{} ->
1570-
" This is most likely an expected change in the serialization format,"
1571-
<> " which currently requires a chain replay"
1570+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotFailed{} ->
1571+
" This is most likely an expected change in the serialization format,"
1572+
<> " which currently requires a chain replay"
1573+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotDataCorruption ->
1574+
" The checksum does not match the snapshot. Seems like the snapshot is corrupted"
1575+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotInvalidChecksumFile{} ->
1576+
" The checksum file contains malformed json"
1577+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotNoChecksumFile{} ->
1578+
" Snapshot checksum checks are enabled but the snapshot had no checksum file."
1579+
<> " Did you intend to disable them with `\"DoDiskSnapshotChecksum\": True` in the configuration file?"
15721580
_ -> ""
15731581
forHuman (LedgerDB.SnapshotMissingChecksum snap) =
1574-
Text.unwords ["Snapshot missing checksum", showT snap]
1582+
"Checksum file is missing for snapshot " <> showT snap
15751583

15761584
forMachine dtals (LedgerDB.TookSnapshot snap pt enclosedTiming) =
15771585
mconcat [ "kind" .= String "TookSnapshot"
@@ -1586,19 +1594,20 @@ instance ( StandardHash blk
15861594
, "snapshot" .= forMachine dtals snap
15871595
, "failure" .= show failure ]
15881596
forMachine dtals (LedgerDB.SnapshotMissingChecksum snap) =
1589-
mconcat [ "kind" .= String "MissingChecksum"
1590-
, "snapshot" .= forMachine dtals snap ]
1597+
mconcat [ "kind" .= String "SnapshotMissingChecksum"
1598+
, "snapshot" .= forMachine dtals snap
1599+
]
15911600

15921601
instance MetaTrace (LedgerDB.TraceSnapshotEvent blk) where
15931602
namespaceFor LedgerDB.TookSnapshot {} = Namespace [] ["TookSnapshot"]
15941603
namespaceFor LedgerDB.DeletedSnapshot {} = Namespace [] ["DeletedSnapshot"]
15951604
namespaceFor LedgerDB.InvalidSnapshot {} = Namespace [] ["InvalidSnapshot"]
1596-
namespaceFor LedgerDB.SnapshotMissingChecksum {} = Namespace [] ["MissingChecksum"]
1605+
namespaceFor LedgerDB.SnapshotMissingChecksum {} = Namespace [] ["SnapshotMissingChecksum"]
15971606

15981607
severityFor (Namespace _ ["TookSnapshot"]) _ = Just Info
15991608
severityFor (Namespace _ ["DeletedSnapshot"]) _ = Just Debug
16001609
severityFor (Namespace _ ["InvalidSnapshot"]) _ = Just Error
1601-
severityFor (Namespace _ ["MissingChecksum"]) _ = Just Error
1610+
severityFor (Namespace _ ["SnapshotMissingChecksum"]) _ = Just Warning
16021611
severityFor _ _ = Nothing
16031612

16041613
documentFor (Namespace _ ["TookSnapshot"]) = Just $ mconcat
@@ -1610,15 +1619,15 @@ instance MetaTrace (LedgerDB.TraceSnapshotEvent blk) where
16101619
"A snapshot was deleted from the disk."
16111620
documentFor (Namespace _ ["InvalidSnapshot"]) = Just
16121621
"An on disk snapshot was invalid. Unless it was suffixed, it will be deleted"
1613-
documentFor (Namespace _ ["MissingChecksum"]) = Just
1614-
"Snapshot is missing checksum"
1622+
documentFor (Namespace _ ["SnapshotMissingChecksum"]) = Just
1623+
"Checksum file was missing for snapshot."
16151624
documentFor _ = Nothing
16161625

16171626
allNamespaces =
16181627
[ Namespace [] ["TookSnapshot"]
16191628
, Namespace [] ["DeletedSnapshot"]
16201629
, Namespace [] ["InvalidSnapshot"]
1621-
, Namespace [] ["MissingChecksum"]
1630+
, Namespace [] ["SnapshotMissingChecksum"]
16221631
]
16231632

16241633

cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import qualified Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types as ImmDB
6969
import Ouroboros.Consensus.Storage.LedgerDB (PushGoal (..), PushStart (..), Pushing (..),
7070
ReplayStart (..))
7171
import qualified Ouroboros.Consensus.Storage.LedgerDB as LedgerDB
72+
import qualified Ouroboros.Consensus.Storage.LedgerDB.Snapshots as LedgerDB
7273
import qualified Ouroboros.Consensus.Storage.VolatileDB.Impl as VolDb
7374
import Ouroboros.Consensus.Util.Condense
7475
import Ouroboros.Consensus.Util.Enclose
@@ -173,7 +174,7 @@ instance HasSeverityAnnotation (ChainDB.TraceEvent blk) where
173174
LedgerDB.TookSnapshot {} -> Info
174175
LedgerDB.DeletedSnapshot {} -> Debug
175176
LedgerDB.InvalidSnapshot {} -> Error
176-
LedgerDB.SnapshotMissingChecksum {} -> Error
177+
LedgerDB.SnapshotMissingChecksum {} -> Warning
177178

178179
getSeverityAnnotation (ChainDB.TraceCopyToImmutableDBEvent ev) = case ev of
179180
ChainDB.CopiedBlockToImmutableDB {} -> Debug
@@ -599,11 +600,19 @@ instance ( ConvertRawHash blk
599600
"Invalid snapshot " <> showT snap <> showT failure <> context
600601
where
601602
context = case failure of
602-
LedgerDB.InitFailureRead{} ->
603+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotFailed{} ->
603604
" This is most likely an expected change in the serialization format,"
604605
<> " which currently requires a chain replay"
606+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotDataCorruption ->
607+
" The checksum does not match the snapshot. Seems like the snapshot is corrupted"
608+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotInvalidChecksumFile{} ->
609+
" The checksum file contains malformed json"
610+
LedgerDB.InitFailureRead LedgerDB.ReadSnapshotNoChecksumFile{} ->
611+
" Snapshot checksum checks are enabled but the snapshot had no checksum file."
612+
<> " Did you intend to disable them with `\"DoDiskSnapshotChecksum\": True` in the configuration file?"
605613
_ -> ""
606-
614+
LedgerDB.SnapshotMissingChecksum snap ->
615+
"Checksum file is missing for snapshot " <> showT snap
607616
LedgerDB.TookSnapshot snap pt RisingEdge ->
608617
"Taking ledger snapshot " <> showT snap <>
609618
" at " <> renderRealPointAsPhrase pt
@@ -613,8 +622,6 @@ instance ( ConvertRawHash blk
613622
", duration: " <> showT t
614623
LedgerDB.DeletedSnapshot snap ->
615624
"Deleted old snapshot " <> showT snap
616-
LedgerDB.SnapshotMissingChecksum snap ->
617-
"Missing snapshot checksum " <> showT snap
618625
ChainDB.TraceCopyToImmutableDBEvent ev -> case ev of
619626
ChainDB.CopiedBlockToImmutableDB pt ->
620627
"Copied block " <> renderPointAsPhrase pt <> " to the ImmutableDB"
@@ -1060,7 +1067,7 @@ instance ( ConvertRawHash blk
10601067
, "snapshot" .= toObject verb snap
10611068
, "failure" .= show failure ]
10621069
LedgerDB.SnapshotMissingChecksum snap ->
1063-
mconcat [ "kind" .= String "TraceSnapshotEvent.InvalidSnapshot"
1070+
mconcat [ "kind" .= String "TraceSnapshotEvent.SnapshotMissingChecksum"
10641071
, "snapshot" .= toObject verb snap
10651072
]
10661073

0 commit comments

Comments
 (0)