-
Notifications
You must be signed in to change notification settings - Fork 160
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
error : it has to be a leader!!! #920
Comments
👋 Thanks for opening this issue! Get help or engage by:
|
A panic is a logic bug. Could you provide the debug level logs? This way I can see what's happening when it panicked. |
|
What steps did you take to arrive at this particular status? From the provided log, it appears that the membership is empty:
and the vote is non-empty:
The lack of initialization for Openraft is evident, since an empty membership is not permissible when initializing Openraft. Reason and SolutionOpenraft's handling of this unexpected scenario seems inconsistent. In this context:
Given that
Added 2023-11-06: To resolve this issue, I will update For node-2:
|
Openraft does not require Leader/Candidate to be a voter. Before this commit, Openraft's handling of non-voter leader is inconsistent: For a node that has a vote proposed by this node and is committed, and is not a voter: - [`calc_server_state()`](https://github.com/datafuselabs/openraft/blob/97254a31c673e52429ee7187de96fd2ea2a5ce98/openraft/src/raft_state/mod.rs#L323) returns `Learner`. - But [`is_leader()`](https://github.com/datafuselabs/openraft/blob/97254a31c673e52429ee7187de96fd2ea2a5ce98/openraft/src/raft_state/mod.rs#L353) returns true. Since this commit, `calc_server_state()` and `is_leader()` returns consistent result according to the following table: For node-2: - Node-2 with vote `(term=1, node_id=2, committed=true)`: - is a leader if it is **present** in config, either a voter or non-voter. - is a learner if it is **absent** in config. - Node-2 with vote `(term=1, node_id=2, committed=false)`: - is a candidate if it is **present** in config, either a voter or non-voter. - is a learner if it is **absent** in config. - Node-3 with vote `(term=1, node_id=99, committed=false|true)`: - is a follower if it is a **voter** in config, - is a learner if it is a **non-voter** or **absent** in config. | vote \ membership | Voter | Non-voter | Absent | |---------------------------------------|-----------|-----------|---------| | (term=1, node_id=2, committed=true) | leader | leader | learner | | (term=1, node_id=2, committed=false) | candidate | candidate | learner | | (term=1, node_id=99, committed=true) | follower | learner | learner | | (term=1, node_id=99, committed=false) | follower | learner | learner | - Fix: databendlabs#920
Openraft does not require Leader/Candidate to be a voter. Before this commit, Openraft's handling of non-voter leader is inconsistent: For a node that has a vote proposed by this node and is committed, and is not a voter: - [`calc_server_state()`](https://github.com/datafuselabs/openraft/blob/97254a31c673e52429ee7187de96fd2ea2a5ce98/openraft/src/raft_state/mod.rs#L323) returns `Learner`. - But [`is_leader()`](https://github.com/datafuselabs/openraft/blob/97254a31c673e52429ee7187de96fd2ea2a5ce98/openraft/src/raft_state/mod.rs#L353) returns true. Since this commit, `calc_server_state()` and `is_leader()` returns consistent result according to the following table: For node-2: - Node-2 with vote `(term=1, node_id=2, committed=true)`: - is a leader if it is **present** in config, either a voter or non-voter. - is a learner if it is **absent** in config. - Node-2 with vote `(term=1, node_id=2, committed=false)`: - is a candidate if it is **present** in config, either a voter or non-voter. - is a learner if it is **absent** in config. - Node-3 with vote `(term=1, node_id=99, committed=false|true)`: - is a follower if it is a **voter** in config, - is a learner if it is a **non-voter** or **absent** in config. | vote \ membership | Voter | Non-voter | Absent | |---------------------------------------|-----------|-----------|---------| | (term=1, node_id=2, committed=true) | leader | leader | learner | | (term=1, node_id=2, committed=false) | candidate | candidate | learner | | (term=1, node_id=99, committed=true) | follower | learner | learner | | (term=1, node_id=99, committed=false) | follower | learner | learner | - Fix: databendlabs#920
The following PR is merged. In your case, the node should start as a |
Describe the bug
I started a node, then set the node as leader, then ctrl+c crashed the node, and then the following error occurred when restarting the node.
Is this normal logic or a bug?
The text was updated successfully, but these errors were encountered: