{"record":{"id":"4286dad813292f8c","repo":"nats-io/nats-server","slug":"error-writing-term-and-vote-file-for-q-v","errorCode":null,"errorMessage":"Error writing term and vote file for %q: %v","messagePattern":"Error writing term and vote file for %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":5540,"sourceCode":"\t}\n\n\tvar buf [termVoteLen]byte\n\tvar le = binary.LittleEndian\n\tle.PutUint64(buf[0:], n.term)\n\tcopy(buf[8:], n.vote)\n\tb := buf[:8+len(n.vote)]\n\n\t// If the term and vote hasn't changed then don't rewrite to disk.\n\tif bytes.Equal(n.wtv, b) {\n\t\treturn nil\n\t}\n\t// Stamp latest and write the term & vote file.\n\tn.wtv = b\n\tif err := writeTermVote(n.dios, n.sd, n.wtv); err != nil && !n.isClosed() {\n\t\t// Clear wtv since we failed.\n\t\tn.wtv = nil\n\t\tn.setWriteErrLocked(err)\n\t\tn.warn(\"Error writing term and vote file for %q: %v\", n.group, err)\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// voteResponse is a response to a vote request.\ntype voteResponse struct {\n\tterm    uint64\n\tpeer    string\n\tgranted bool\n\tempty   bool // \"Empty vote\", whether this peer's log is empty.\n}\n\nconst voteResponseLen = 8 + 8 + 1\n\nfunc (vr *voteResponse) encode() []byte {\n\tvar buf [voteResponseLen]byte\n\tvar le = binary.LittleEndian","sourceCodeStart":5522,"sourceCodeEnd":5558,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L5522-L5558","documentation":"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.","triggerScenarios":"Thrown at server/raft.go:5540 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","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-08T15:18:49.778Z"}