Bug 7362: Notify applyState synchronously
As per comments in bug 7362, it's problematic for snapshots that we
set lastApplied index but queue the ApplyState message. This can leave
the derived actor's captured state out-of-sync with the lastApplied index
if a snapshot occurs in between. We need to set lastApplied atomically
with apply to state so I added a callback that RaftActor sets in the
RaftActorContext that is called by the behavior's applyLogToStateMachine
method. The callback immediately calls applyState. The ApplyState message
is still queued for other compenents that trigger on it (and also unit
tests).
I considered setting lastApplied when the ApplyState message is processed,
and not in applyLogToStateMachine, but this would be problematic if
another AppendEntriesReply was queued before the ApplyState message
as it would try to apply it again.
Change-Id: Ie062af8440bc251eec9c9ef58f450dee23abd04c
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
20 files changed: