{"record":{"id":"89c2dd8cc9eacd99","repo":"nats-io/nats-server","slug":"got-an-error-re-encoding-append-entry-v","errorCode":null,"errorMessage":"Got an error re-encoding append entry: %v","messagePattern":"Got an error re-encoding append entry: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":3674,"sourceCode":"\n\tsendNext := func() bool {\n\t\tfor total <= maxOutstanding {\n\t\t\tnext++\n\t\t\tif next > last {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tae, err := n.loadEntry(next)\n\t\t\tif err != nil {\n\t\t\t\tif err != ErrStoreEOF {\n\t\t\t\t\tn.warn(\"Got an error loading %d index: %v\", next, err)\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t}\n\t\t\t// Re-encode with the lterm if needed\n\t\t\tif ae.lterm != term {\n\t\t\t\tae.lterm = term\n\t\t\t\tif ae.buf, err = ae.encode(ae.buf[:0]); err != nil {\n\t\t\t\t\tn.warn(\"Got an error re-encoding append entry: %v\", err)\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Update our tracking total.\n\t\t\tom[next] = len(ae.buf)\n\t\t\ttotal += len(ae.buf)\n\t\t\tn.sendRPC(subj, reply, ae.buf)\n\t\t}\n\t\treturn false\n\t}\n\n\tconst activityInterval = 2 * time.Second\n\ttimeout := time.NewTimer(activityInterval)\n\tdefer timeout.Stop()\n\n\tstepCheck := time.NewTicker(100 * time.Millisecond)\n\tdefer stepCheck.Stop()\n","sourceCodeStart":3656,"sourceCodeEnd":3692,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L3656-L3692","documentation":"While re-encoding a log entry for a catching-up follower (rewriting its lterm to the leader's current term), appendEntry.encode failed. This indicates a malformed or internally inconsistent entry buffer, and the send loop for that batch is abandoned.","triggerScenarios":"Thrown at server/raft.go:3674 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Capture the error to identify why encode failed (usually a corrupt entry in the WAL)","Consider truncating the WAL or re-snapshotting so the offending entry is regenerated","Report as a bug if it recurs on valid data"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}