[Minor] Former candidate can vote twice in one term
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 876
- Forks
- 260
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 157
Description
Former candidates can vote twice in one term in CCF Raft. This is not a safe violation as it cannot lead to two leaders in a term but it is something we might want to address at some point (or we will need to update the spec accordingly)
Steps:
1) Node A becomes a candidate in some term, say 3
2) However, another node (node B) is elected leader of term 3
3) Node B sends an AE message to node A in term 3. Node A will step down to a follower in term 3
In the process of stepping down, `raft.h` calls `become_aware_of_new_term` and the `voted_for` field is reset, allowing the node to vote again.
https://github.com/microsoft/CCF/blob/61d6c1824f80d4714d9006b5292f2cff57473d5a/src/consensus/aft/raft.h#L1017-L1012
This report is just based of code inspection, it would be useful to generate a trace of this in practice
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/consensus/aft/raft.h at the linked become_aware_of_new_term call and trace the candidate-to-follower transition. Reproduce the reported sequence with a trace if possible, confirming whether voted_for is reset and permits a second vote in the same term. Done means the behavior is confirmed and the appropriate code or specification change is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100