Skip to content

Commit 7ae65b3

Browse files
[IMPROVED] NRG: Clarify log when resetting WAL (#6938)
Usually `Resetting WAL state` is a prime indicator something went horribly wrong with replication, and resetting is our last effort at fixing things. Antithesis reports on this being logged so we can look into it and fix the condition. However, this also triggers if the WAL is empty, a leader gets elected and stores a message that doesn't get quorum. Once a new leader is elected and this entry without quorum gets removed, we'd also log `Resetting WAL state` even though this is a normal condition. If we have made no commits, it's safe to reset/clear the WAL. This PR changes the log line to clarify this. Relates to #6705 Signed-off-by: Maurice van Veen <[email protected]>
2 parents 40d87cc + 83f6e59 commit 7ae65b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/raft.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3259,7 +3259,11 @@ func (n *raft) truncateWAL(term, index uint64) {
32593259
n.debug("Truncating and repairing WAL to Term %d Index %d", term, index)
32603260

32613261
if term == 0 && index == 0 {
3262-
n.warn("Resetting WAL state")
3262+
if n.commit > 0 {
3263+
n.warn("Resetting WAL state")
3264+
} else {
3265+
n.debug("Clearing WAL state (no commits)")
3266+
}
32633267
}
32643268

32653269
defer func() {

0 commit comments

Comments
 (0)