From c8491c0e237b58292bd35bf5dd25e57442172b07 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Wed, 12 Nov 2025 15:24:08 -0800 Subject: [PATCH] Warn when root record rolls backwards --- go/store/nbs/journal_inspect.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/go/store/nbs/journal_inspect.go b/go/store/nbs/journal_inspect.go index a8489f1687..340b4150b1 100644 --- a/go/store/nbs/journal_inspect.go +++ b/go/store/nbs/journal_inspect.go @@ -23,6 +23,7 @@ import ( "io" "os" "slices" + "time" "github.com/sirupsen/logrus" ) @@ -71,6 +72,8 @@ func JournalInspect(journalPath string, seeRoots, seeChunks, crcScan, snapScan b // suspectRegionStart is the offset of an unparsable region. Used to process bad regions when they come up. suspectRegionStart := -1 + var lastRootTs time.Time + shasum := sha256.Sum256(buf) logrus.Infof("Read %d bytes with sha256 sum: %s", len(buf), hex.EncodeToString(shasum[:])) @@ -155,6 +158,14 @@ func JournalInspect(journalPath string, seeRoots, seeChunks, crcScan, snapScan b logrus.Infof("Chunk Record Found %s (%d bytes)", rec.address.String(), len(recordBuf)) } } else if rec.kind == rootHashJournalRecKind { + if lastRootTs.IsZero() { + lastRootTs = rec.timestamp + } + if rec.timestamp.Before(lastRootTs) { + logrus.Warnf("Root record timestamp went backwards: last %s, this %s", lastRootTs.String(), rec.timestamp.String()) + } + lastRootTs = rec.timestamp + numRoots += 1 if firstHealthy { logrus.Infof("First Root Record Found %s (%d bytes)", rec.address.String(), len(recordBuf))