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 4ce84bd11f8ed8edccc4d8699a5202850dbef5be..035821006d666b838a888f3429319442676f67bb 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 23a0f6d027c53841644a6ab1c5273708a9e0a011..18881ecd4e69a85ebffc9394101310caac51f3b1 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();
+    }
 }