This is an automated email from the ASF dual-hosted git repository.
angerszhuuuu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new ce86e11d [CELEBORN-133] Improve snapshot loading (#1078)
ce86e11d is described below
commit ce86e11d50fc766da34d690d97b8f09509e91e36
Author: William Song <[email protected]>
AuthorDate: Wed Dec 14 14:26:31 2022 +0800
[CELEBORN-133] Improve snapshot loading (#1078)
Co-authored-by: Cheng Pan <[email protected]>
---
.../deploy/master/clustermeta/ha/StateMachine.java | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git
a/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/StateMachine.java
b/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/StateMachine.java
index d6a82db6..51e8dcba 100644
---
a/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/StateMachine.java
+++
b/master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/StateMachine.java
@@ -17,7 +17,10 @@
package org.apache.celeborn.service.deploy.master.clustermeta.ha;
-import static org.apache.ratis.util.LifeCycle.State.*;
+import static org.apache.ratis.util.LifeCycle.State.PAUSED;
+import static org.apache.ratis.util.LifeCycle.State.PAUSING;
+import static org.apache.ratis.util.LifeCycle.State.RUNNING;
+import static org.apache.ratis.util.LifeCycle.State.STARTING;
import java.io.File;
import java.io.FileNotFoundException;
@@ -207,6 +210,10 @@ public class StateMachine extends BaseStateMachine {
if (snapshot == null) {
return;
}
+ if (snapshot.getTermIndex().compareTo(getLastAppliedTermIndex()) <= 0) {
+ LOG.info("obsolete snapshot provided: {}", snapshot.getTermIndex());
+ return;
+ }
LOG.info("Loading Snapshot {}.", snapshot);
final File snapshotFile = snapshot.getFile().getPath().toFile();
if (!snapshotFile.exists()) {
@@ -216,16 +223,18 @@ public class StateMachine extends BaseStateMachine {
try {
setLastAppliedTermIndex(snapshot.getTermIndex());
install(snapshotFile);
- } catch (Exception e) {
- throw new IOException(String.format("Failed to load snapshot %s",
snapshot), e);
+ } catch (IOException rethrow) {
+ LOG.error("Failed to load snapshot {}", snapshot);
+ throw rethrow;
}
}
- private void install(File snapshotFile) {
+ private void install(File snapshotFile) throws IOException {
try {
metaHandler.loadSnapShot(snapshotFile);
- } catch (Exception e) {
- LOG.warn("Failed to install snapshot!", e);
+ } catch (IOException rethrow) {
+ LOG.warn("Failed to install snapshot!", rethrow);
+ throw rethrow;
}
LOG.info("Successfully installed snapshot!");
}