ktoso / akka-raft

A toy project implementing RAFT on top of Akka Cluster (not prod ready)
http://blog.project13.pl
Apache License 2.0
280 stars 42 forks source link

termAt can return wrong term for first item #38

Open schuster opened 9 years ago

schuster commented 9 years ago

The termAt method will return the wrong term in the case where the first entry in the log actually comes from a term other than term 1 (could happen if multiple elections occur before a request is sent). This is related to the inconsistent use of index numbers - the test should be for an index less than 0, not less than or equal to.

colin-scott commented 9 years ago

For what it's worth, I have a (non-pull-request-worthy) fix for this issue here:

NetSys/sts2-applications@1840499

Tested by fuzz testing -- I verified that under non-failing scenarios, this behaves correctly at each step of the execution when replicated two client commands.