Fix AppendEntry logic when prevLogIndex and prevLogTerm is -1 46/24546/2
authorMoiz Raja <moraja@cisco.com>
Mon, 13 Jul 2015 20:31:42 +0000 (13:31 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 25 Jul 2015 01:22:00 +0000 (01:22 +0000)
commite9bf41afa2413cc4574a7ac97a55f2cb6c2de6b2
tree1a8672508fcd3c6e73ac84c6a82988c6f4714e0d
parenta37aef6c01f720b935535b11cf9d7689ceea9470
Fix AppendEntry logic when prevLogIndex and prevLogTerm is -1

When an AppendEntry arrives at a Follower with the prevLogIndex and
prevLogTerm = -1 the Follower will accept that append entry and add it
to the log. For a newly started Follower this can be problematic
because this will be the first entry in that Followers log and so
applying this entry to the Follower's state can end up corrupting the
state or cause failures in committing transactions.

To fix this we now verify if the replicatedToAllIndex is present in the
Followers log. If it is present then the log is considered in sync else
not.

Change-Id: I09bead430f1a4556182263de54846792668cd27c
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 0efdc8e538815024cc54955be0b55ebec0321be6)
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Follower.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.