jasonrogena / lightraft

Wrapper around SQLite that makes it distributed. This is an experiment, don't use in production
11 stars 2 forks source link

Updates AppendEntries Function to Match Raft Paper #11

Closed jasonrogena closed 4 years ago

jasonrogena commented 4 years ago

There were certain steps that need to be done before appending an entry, as stated in the Raft paper, that weren't being done:

  1. Reply false if term < currentTerm (section 5.1)
  2. Reply false if log doesn't contain an entry at prevLogIndex whose term matches prevLogTerm (section 5.3).
  3. If an existing entry conflicts with a new one (same index but different terms), delete the existing entry and all that follow it (section 5.3).

Having these steps will help with reconciling with a leader in-case of a conflict between the log of the follower and the leader.

TODO: Add tests to newly added functionality.

Fixes #10