From fba74fb93e947ecde93ef6685ef6303d2a8bb947 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 11 Mar 2015 18:11:33 -0400 Subject: [PATCH] Purge in-memory log when install snapshot is done In AbstractLeader#handleInstallSnapshotReply, after the last snapshot chunk has been sent and acknowledged by the follower and, since install snapshot *should* only happen for a lagging follower, the follower is most likely caught up at this point so we can be greedy and try to trim the log and advance replicatedToAllIndex. Change-Id: Id22dfbcb6e459e3d3f6801d1c6c850bdd42989fa Signed-off-by: Tom Pantelis --- .../controller/cluster/raft/behaviors/AbstractLeader.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java index 890d45e8fb..831f8f9e70 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java @@ -383,7 +383,10 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { followerToSnapshot.markSendStatus(false); } - if (!wasLastChunk && followerToSnapshot.canSendNextChunk()) { + if (wasLastChunk && !context.isSnapshotCaptureInitiated()) { + // Since the follower is now caught up try to purge the log. + purgeInMemoryLog(); + } else if (!wasLastChunk && followerToSnapshot.canSendNextChunk()) { ActorSelection followerActor = context.getPeerActorSelection(followerId); if(followerActor != null) { sendSnapshotChunk(followerActor, followerId); -- 2.36.6