-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialization with term=0 shouldn't be allowed #511
Comments
Then term should be assigned to vote response. |
It is assigned, but the term is still 0 when the node initializes, unless I misunderstood what you were referring to. |
I see. When the raft group is first initialized, it should not have term 0 (INVALID_TERM). |
@BusyJay makes sense, thank you! |
Perhaps we check it on initial state loaded? I encountered this issue days before also. |
There are two cases: 1. constructing the raft node with existing data, so the node is already initialized and should have a valid term; 2. constructing the raft node without any data, so the node is not initialized and can have term 0. Though adding a check that term must not be 0 if configuration is not empty should be OK. |
I can work on a PR for that. |
Please send it when you are free, thanks! |
Reopened |
Created a PR - #513 |
Came here to open a similar issue and I think it fits here. I would propose to remove stuff like |
Describe the bug
Nodes often crashing (
panic
) during first few moments of Raft, when using distinctpriority
values per node together withpre_vote = true
.The least-prioritized node never crashes.
When I looked into it, I found that it's because during the pre-voting, we reject pre-voting requests from lower-priority nodes:
https://github.com/tikv/raft-rs/blob/82d704cdc3d93258be1f45efd715b95930764d7f/src/raft.rs#L1467C65-L1467C98
We then try to send the rejection back to the proposing node, including our term as the message's term:
https://github.com/tikv/raft-rs/blob/82d704cdc3d93258be1f45efd715b95930764d7f/src/raft.rs#L1494C21-L1498C58
But during that send, term is checked to be != 0, resulting in a panic instead of sending the proposal rejection:
https://github.com/tikv/raft-rs/blob/82d704cdc3d93258be1f45efd715b95930764d7f/src/raft.rs#L617C9-L640C14
Expected behavior
PreVoting rejection and not
panic()
.The text was updated successfully, but these errors were encountered: