Reject Bootstrap on a Storage that holds a HardState
perfloop-oss/raft · Uncatalogued correctness
https://perfloop.ai/t/oss/case_xxh5jcerev
Verdict
VERIFIED · settled 2026-11-10 · pull request opened as etcd-io/raft#553
What happened: The check fails before this change and passes with it.
Hypothesis
Bootstrapping can erase a node's loaded election term and vote when its log has no entries. The submitter reports that this permits votes for two candidates in one term. That safety outcome needs independent confirmation; deployment prevalence is unknown.
The RawNode.Bootstrap documentation promises an error when Storage is nonempty (bootstrap.go:25–27). Its storage gate checks only LastIndex() != 0 (bootstrap.go:36–43), then clears prevHardSt and calls becomeFollower(1, None) (bootstrap.go:45–52). NewRawNode loads stored HardState through newRaft (rawnode.go:51–60; raft.go:444–487). Changing the term through becomeFollower clears the loaded vote (raft.go:781–785, 891–900). MemoryStorage stores HardState independently of its entry count (storage.go:129–141, 184–193).
At HEAD c51f010c851edd0dada5af41bafbf68e54617767, the submitter reports that Storage with HardState {Term:5, Vote:2} and no entries makes Bootstrap return nil. The node then moves to term 1 with no vote and later grants another candidate a vote in term 5, producing MsgVoteResp with reject=false. The reported control without Bootstrap rejects that vote. The Case must check these reported results and the one-vote-per-term property rather than assume the report is established evidence.
Reach is narrow: an application must call Bootstrap on such Storage. Normal recovery is documented separately via RestartNode (README.md:90–110); no production occurrence is claimed. The zero-index snapshot half of the original concern is explicitly out of scope. Merged https://github.com/etcd-io/raft/pull/370 deliberately permits configuration-only snapshots at index and term zero, and that behavior remains in storage.go:218–236.
The smallest useful next check is a focused Go regression test comparing the bootstrap attempt with the no-bootstrap control, checking the returned error, retained election state, and same-term vote response through the normal Ready/persistence protocol. It must show no second vote in the same term and retain PR 370 snapshot behavior. The exact diagnostic setup and test placement are provisional, not extra frozen requirements.
The submitter found no upstream report. The current complete open-PR listing and inspected overlapping patches did not reveal this HardState guard. https://github.com/etcd-io/raft/pull/454 changes bootstrap-test storage-error assertions, not this gate. https://github.com/etcd-io/raft/pull/550 changes asynchronous vote-request durability ordering, not Bootstrap's reset of loaded state. Other inspected Bootstrap hunks concern tracing, witnesses, or append-term plumbing. Recent merged-file history remains a gap: the checkout is shallow and the bounded code-host history request was refused. This review is not an exhaustive issue or archive search.
Change to test: Treat a Storage with non-empty HardState as nonempty and return an error from RawNode.Bootstrap before resetting election state. Preserve PR 370's zero-index snapshot behavior and add a regression test showing no second vote in the same term.
Where it lives
Evidence
The check fails before this change and passes with it: `With an empty log and a durable term-5 vote for candidate 2, RawNode.Bootstrap rejects the Storage without changing election state or producing Ready work; after Ready persistence, a term-5 vote request from candidate 3 is rejected, as without Bootstrap.`
Checks: 3 of 3 passed. Verification: no defect found.
Timeline
2026-11-10· Case opened2026-11-10· PR opened