Skip to content
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

Node goes from follower to leader state #17

Closed
danluu opened this issue Sep 16, 2017 · 2 comments
Closed

Node goes from follower to leader state #17

danluu opened this issue Sep 16, 2017 · 2 comments

Comments

@danluu
Copy link
Collaborator

danluu commented Sep 16, 2017

If we look at a trace of node state transitions, we see that a node goes from candidate to follower to leader. It should probably not become a follower in between the candidate and leader states:

src/world_broker.py execute_step
timer_trip 2
change_type 2: Follower -> Candidate
change_type 2: Candidate -> Follower
change_type 4: Follower -> Follower
change_type 3: Follower -> Follower
change_type 2: Follower -> Leader
change_type 1: Follower -> Follower
change_type 2: Leader -> Leader
change_type 0: Follower -> Follower
change_type 2: Leader -> Leader
@danluu
Copy link
Collaborator Author

danluu commented Sep 16, 2017

I believe the issue is:

  1. In timer_trip, a node becoming a candidate increases its term:
        if not self.is_leader():
            self.change_type('Candidate')
            self.update_term(self.term+1)
  1. This means that we compare self.term to self.term + 1. self.term < self.term + 1, therefore we become a follower.

  2. Due to perhaps another bug, we don't block followers from becoming leaders. If we get a response that's "successful", the node becomes a leader regardless of its current state.

danluu added a commit that referenced this issue Sep 16, 2017
@danluu
Copy link
Collaborator Author

danluu commented Sep 16, 2017

Jinny and I pushed a fix for this in the test branch. However, this involves adding a boolean flag to update_term, which is sort of ugly. Does anyone have a better idea on how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant