[Bug] Fix bug that checkpoint thread failed to start (#3795)

1. Set thread id before starting the checkpoint thread
2. Init the CHECKPOINT catalog instance before visiting it.
This commit is contained in:
Mingyu Chen
2020-06-08 23:00:36 +08:00
committed by GitHub
parent 559714f3d4
commit 8ada2559b7
4 changed files with 11 additions and 12 deletions

View File

@ -72,7 +72,6 @@ public class PaloFe {
return;
}
CommandLineOptions cmdLineOpts = parseArgs(args);
System.out.println(cmdLineOpts.toString());

View File

@ -541,16 +541,13 @@ public class Catalog {
}
}
// use this to get CheckPoint Catalog instance
public static Catalog getCheckpoint() {
if (CHECKPOINT == null) {
CHECKPOINT = new Catalog();
}
return CHECKPOINT;
}
public static Catalog getCurrentCatalog() {
if (isCheckpointThread()) {
// only checkpoint thread it self will goes here.
// so no need to care about the thread safe.
if (CHECKPOINT == null) {
CHECKPOINT = new Catalog();
}
return CHECKPOINT;
} else {
return SingletonHolder.INSTANCE;
@ -1204,8 +1201,11 @@ public class Catalog {
// start checkpoint thread
checkpointer = new Checkpoint(editLog);
checkpointer.setMetaContext(metaContext);
checkpointer.start();
// set "checkpointThreadId" before the checkpoint thread start, because the thread
// need to check the "checkpointThreadId" when running.
checkpointThreadId = checkpointer.getId();
checkpointer.start();
LOG.info("checkpointer thread started. thread id is {}", checkpointThreadId);
// heartbeat mgr

View File

@ -115,7 +115,7 @@ public class Daemon extends Thread {
try {
runOneCycle();
} catch (Throwable e) {
LOG.error("daemon thread got exception: ", e);
LOG.error("daemon thread got exception. name: {}", getName(), e);
}
try {

View File

@ -94,7 +94,7 @@ public class Checkpoint extends MasterDaemon {
long replayedJournalId = -1;
// generate new image file
LOG.info("begin to generate new image: image.{}", checkPointVersion);
catalog = Catalog.getCheckpoint();
catalog = Catalog.getCurrentCatalog();
catalog.setEditLog(editLog);
try {
catalog.loadImage(imageDir);