-
Notifications
You must be signed in to change notification settings - Fork 143
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
Redundant information in LeaderId::node_id
#652
Comments
👋 Thanks for opening this issue! Get help or engage by:
|
I added a Given 3 nodes, if all of them start to elect at the same time, with the same
Because they all have already voted for themselves, they just reject every received vote request from other nodes. This is the way the standard raft does But with
It has to compare It looks I have to add some tests for such a case:(
This is the only location where it is explicitly used. When handling a vote request, a node just compares votes with |
Hm, I still don't get it. The standard Raft uses only In the first case you described (all start voting for self at the exact time), there would be no leader elected for this term, which would trigger another election with a new term. The likelihood that even the second election again occurs at exact the same time on all nodes (and fails too) is virtually zero. When I understand you correctly, you only store The vote handling compares log ID (i.e., term + log index). That should be sufficient, since the same |
In standard raft, a leader is not just identified by The And this partial-order In openraft
Right, the chance there is another round of conflict is rare. But still, it takes two rounds of election. The time gap between these two rounds will be considered service downtime(about 2 RTT).
Generally speaking, yes:). And it simplifies the logic. Adding another field will save several lines of code that handle
Hm... to me, with or without a |
Wow, what a long explanation :-), thanks. I was imprecise, sorry. Of course, (one) voted-for node ID needs to be stored and the So we can conclude that the Alternatively, looking at the code again, it seems like I'll probably go with the above mentioned storage optimization in the log ("switch" entries) or we'll store our 16B node IDs for each log entry anyway. |
I have a LogIdList structure that contains every log id from which a new In fact, in my opinion, such a structure reflects more precisely the data structure in raft. May be I can introduce a feature to disable/enable to contain a node-id in LogId. 🤔
I did not know you have such a big node-id :( openraft/openraft/src/membership/membership.rs Lines 73 to 87 in e31b0f9
|
Sure, but considering that Raft doesn't allow to have two leaders for the same
I wouldn't complicate the API and core algorithms. Either-or, I'd say. We have plenty of optimization potential elsewhere (e.g., get rid of
Indeed, I'm thinking about doing exactly that. So far, we didn't use the |
Currently,
LeaderId
contains not onlyterm
, which is sufficient to identify the leader's term and thus also the validity of log entries, but it also containsnode_id
of the leader.This information is redundant, but nevertheless always transported via
LogId
(which subsumesLeaderId
). This leads to unnecessary complexity, since either the node ID of the leader must be logged or otherwise recovered at log replay time.The only location in code where
LeaderId::node_id
is evaluated seems to be inEngine::update_progress()
, where it would likely suffice to compare the term (the same term cannot be used by two different leaders).There is a TODO in
leader_id.rs
already. Most likely, it would be sufficient to simply dropnode_id
from this structure.In any case, removing the comparison for testing purposes doesn't have any effect on test outcome - all green.
My suggestion is to remove the
node_id
member, since it's basically unused and not needed. Going further, maybe the entireLeaderId
structure can be simply replaced byterm
?Or is there some error in my thinking?
Thanks.
The text was updated successfully, but these errors were encountered: