-
Notifications
You must be signed in to change notification settings - Fork 157
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
Refactor: Engine::initialize() sets server state to Candidate #296
Conversation
- Feature: impl TryFrom<BTreeMap> for Membership. - part of databendlabs#292
self.commands.push(Command::MoveInputCursorBy { n: l }); | ||
|
||
// With the new config, start to elect to become leader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can not get the point: why the node init state is candidate instead of follower?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it means no matter the node startup in whatever situation, even if it join a cluster, it must start an election?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After initializing the cluster(by appending a membership log), the cluster should elect a leader ASAP.
The behavior for a follower is to wait for a timeout before starting elect(by entering candidate state). Thus we can just avoid the follower state and enter candidate state at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it means no matter the node startup in whatever situation, even if it join a cluster, it must start an election?
It must be a mistake to join a node into an existing cluster by initialize()
it.
To join, it does not call initialize()
.
It should send a change-membership
RPC to the existing cluster leader to start replicating logs to the new node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it means no matter the node startup in whatever situation, even if it join a cluster, it must start an election?
BTW, the election will never win. The new node does not have any log on it thus it will be rejected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to me that init as a follower or a candidate has not too much different, they all have advantages and disadvantages, as you like:)
Changelog
Refactor: Engine::initialize() sets server state to Candidate
Feature: impl TryFrom for Membership.
part of Impl
initialize()
for engine #292This change is