diff --git a/server/raft.go b/server/raft.go index 773152f4eb5..202f503db17 100644 --- a/server/raft.go +++ b/server/raft.go @@ -31,6 +31,7 @@ import ( "sync/atomic" "time" + "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/nats-io/nats-server/v2/internal/fastrand" "github.com/minio/highwayhash" @@ -3353,6 +3354,14 @@ func (n *raft) truncateWAL(term, index uint64) { n.debug("Clearing WAL state (no commits)") } } + if index < n.commit { + assert.Unreachable("WAL truncate lost commits", map[string]any{ + "term": term, + "index": index, + "commit": n.commit, + "applied": n.applied, + }) + } defer func() { // Check to see if we invalidated any snapshots that might have held state