1
0

[HUDI-1749] Clean/Compaction/Rollback command maybe never exit when operation fail (#2752)

This commit is contained in:
li36909
2021-04-06 14:23:15 +08:00
committed by GitHub
parent e970e1f483
commit 920537cac8
3 changed files with 137 additions and 118 deletions

View File

@@ -83,6 +83,7 @@ public class SparkMain {
? SparkUtil.initJavaSparkConf("hoodie-cli-" + command, Option.of(args[1]), Option.of(args[2]))
: SparkUtil.initJavaSparkConf("hoodie-cli-" + command);
int returnCode = 0;
try {
switch (cmd) {
case ROLLBACK:
assert (args.length == 5);
@@ -199,6 +200,12 @@ public class SparkMain {
default:
break;
}
} catch (Throwable throwable) {
LOG.error("Fail to execute command", throwable);
returnCode = -1;
} finally {
jsc.stop();
}
System.exit(returnCode);
}

View File

@@ -110,6 +110,12 @@ public class HoodieCleaner {
String dirName = new Path(cfg.basePath).getName();
JavaSparkContext jssc = UtilHelpers.buildSparkContext("hoodie-cleaner-" + dirName, cfg.sparkMaster);
try {
new HoodieCleaner(cfg, jssc).run();
} catch (Throwable throwable) {
LOG.error("Fail to run cleaning for " + cfg.basePath, throwable);
} finally {
jssc.stop();
}
}
}

View File

@@ -103,8 +103,14 @@ public class HoodieCompactor {
System.exit(1);
}
final JavaSparkContext jsc = UtilHelpers.buildSparkContext("compactor-" + cfg.tableName, cfg.sparkMaster, cfg.sparkMemory);
try {
HoodieCompactor compactor = new HoodieCompactor(jsc, cfg);
compactor.compact(cfg.retry);
} catch (Throwable throwable) {
LOG.error("Fail to run compaction for " + cfg.tableName, throwable);
} finally {
jsc.stop();
}
}
public int compact(int retry) {