nats-io/nats-server · error
Error writing term and vote file for %q: %v
Error message
Error writing term and vote file for %q: %v
What it means
writeTermVote failed to durably persist the term_vote file recording the current term and granted vote. Raft requires votes to be durable before use, so the caller (vote granting or campaigning) aborts; the cached n.wtv is cleared to force a retry on the next attempt.
Source
Thrown at server/raft.go:5540
}
var buf [termVoteLen]byte
var le = binary.LittleEndian
le.PutUint64(buf[0:], n.term)
copy(buf[8:], n.vote)
b := buf[:8+len(n.vote)]
// If the term and vote hasn't changed then don't rewrite to disk.
if bytes.Equal(n.wtv, b) {
return nil
}
// Stamp latest and write the term & vote file.
n.wtv = b
if err := writeTermVote(n.dios, n.sd, n.wtv); err != nil && !n.isClosed() {
// Clear wtv since we failed.
n.wtv = nil
n.setWriteErrLocked(err)
n.warn("Error writing term and vote file for %q: %v", n.group, err)
return err
}
return nil
}
// voteResponse is a response to a vote request.
type voteResponse struct {
term uint64
peer string
granted bool
empty bool // "Empty vote", whether this peer's log is empty.
}
const voteResponseLen = 8 + 8 + 1
func (vr *voteResponse) encode() []byte {
var buf [voteResponseLen]byte
var le = binary.LittleEndianView on GitHub (pinned to 3a66a489d2)
Solutions
- Check disk space and write permissions on the RAFT store dir
- The vote/campaign is retried on the next election round after the write succeeds
- Persistent failures indicate failing storage; replace or repair the disk
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at server/raft.go:5540 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/4286dad813292f8c.
Report an issue: GitHub.