libraft icon indicating copy to clipboard operation
libraft copied to clipboard

ISE when AppendEntriesReply received from a peer

Open allengeorge opened this issue 10 years ago • 0 comments

Reported by @ZymoticB and noticed in testing on AWS.

Trace from #40

[New I/O worker #4] TRACE io.libraft.algorithm.RaftAlgorithm - agent2: RequestVote from agent1: term:2 lastLogIndex:15 lastLogTerm:1
[New I/O worker #4] INFO io.libraft.algorithm.RaftAlgorithm - agent2: changing role LEADER->FOLLOWER in term 2
[New I/O worker #4] INFO io.libraft.algorithm.RaftAlgorithm - agent2: leader changed from agent2 to null
[New I/O worker #4] TRACE io.libraft.algorithm.RaftAlgorithm - agent2: AppendEntriesReply from agent1: term:2 prevLogIndex:6 entryCount:9 applied:false
[New I/O worker #4] ERROR org.jboss.netty.channel.SimpleChannelUpstreamHandler - agent2: uncaught exception processing rpc:AppendEntriesReply{source=agent1, destination=agent2, term=2, prevLogIndex=6, entryCount=9, applied=false} from agent1
java.lang.IllegalStateException: role:FOLLOWER

This situation can be triggered by the following sequence of events:

Initial State:

  • P1 = LEADER
  • P2 = FOLLOWER
  • Term = 1
  1. P1 sends AppendEntries to P2 in term 1.
  2. P2 has an election timeout and advances to term 2.
  3. P2 sends a REQUEST_VOTE to P1.
  4. P1 receives REQUEST_VOTE and transitions to term 2 and becomes FOLLOWER.
  5. P2 receives AppendEntries sent in step 1.
  6. P2 responds with AppendEntriesReply with term 2 and applied = false.
  7. P1 receives AppendEntriesReply and crashes.

allengeorge avatar Mar 22 '14 23:03 allengeorge