goraft / raft

UNMAINTAINED: A Go implementation of the Raft distributed consensus protocol.
MIT License
2.43k stars 480 forks source link

Writes accepted in a 2 node cluster if the follower is down #118

Closed kellabyte closed 11 years ago

kellabyte commented 11 years ago

If you create a 2 node cluster and kill the follower process you can still issue writes to the leader. I would expect the leader once its discovered the follower is down to go back to trying to elect a new leader but can't because there's not enough nodes to elect one which would cause writes to fail.

I let it run for about 30 minutes and writes were still being accepted.

If you stop both nodes and only start the leader, the leader correctly rejects writes.

benbjohnson commented 11 years ago

The leader doesn't try to re-elect if followers are down. It'll wait until another another node tries to become a candidate.

Are you seeing the writes actually commit against the leader?

xiang90 commented 11 years ago

@benbjohnson @kellabyte There seems to be a problem. I will fix it soon.

xiang90 commented 11 years ago

@benbjohnson @kellabyte We need to sort the commitIndex of peers in descending order. Then we can pick the first majority one as the current CommitedIndex of the whole cluster. I will send a pr.