Reset snapshot progress on IOExceptions 94/82394/6
authorTomas Cere <tomas.cere@pantheon.tech>
Tue, 4 Jun 2019 09:17:10 +0000 (11:17 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 12 Jun 2019 13:39:27 +0000 (13:39 +0000)
Also log the whole LeaderInstallSnapshotState of failures.

Change-Id: I33b1c38f2277f08acbe77bcb0c16d2dfe41d8851
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderInstallSnapshotState.java

index 4ce84bd..0358210 100644 (file)
@@ -944,12 +944,15 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior {
 
                 sendSnapshotChunk(followerActor, followerLogInfo, nextSnapshotChunk, nextChunkIndex, serverConfig);
 
+                log.debug("{}: InstallSnapshot sent to follower {}, Chunk: {}/{}", logName(), followerActor.path(),
+                        installSnapshotState.getChunkIndex(), installSnapshotState.getTotalChunks());
+
             } catch (IOException e) {
-                throw new RuntimeException(e);
+                log.warn("{}: Unable to send chunk: {}/{}. Reseting snapshot progress. Snapshot state: {}", logName(),
+                        installSnapshotState.getChunkIndex(), installSnapshotState.getTotalChunks(),
+                        installSnapshotState);
+                installSnapshotState.reset();
             }
-
-            log.debug("{}: InstallSnapshot sent to follower {}, Chunk: {}/{}", logName(), followerActor.path(),
-                installSnapshotState.getChunkIndex(), installSnapshotState.getTotalChunks());
         }
     }
 
index 23a0f6d..18881ec 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.raft.behaviors;
 
+import com.google.common.base.MoreObjects;
 import com.google.common.base.Stopwatch;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
@@ -200,4 +201,20 @@ public final class LeaderInstallSnapshotState implements AutoCloseable {
     int getLastChunkHashCode() {
         return lastChunkHashCode;
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("snapshotChunkSize", snapshotChunkSize)
+                .add("offset", offset)
+                .add("replyReceivedForOffset", replyReceivedForOffset)
+                .add("replyStatus", replyStatus)
+                .add("chunkIndex", chunkIndex)
+                .add("totalChunks", totalChunks)
+                .add("lastChunkHashCode", lastChunkHashCode)
+                .add("nextChunkHashCode", nextChunkHashCode)
+                .add("snapshotSize", snapshotSize)
+                .add("chunkTimer", chunkTimer)
+                .toString();
+    }
 }

©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.