From b5f60bde42b3a30301824a95e67acfe129336dd8 Mon Sep 17 00:00:00 2001 From: zhangdong <493738387@qq.com> Date: Wed, 17 May 2023 21:33:56 +0800 Subject: [PATCH] [fix](checkpoint)fix Checkpoint error when http server is not ready #19699 --- fe/fe-core/src/main/java/org/apache/doris/DorisFE.java | 1 + .../src/main/java/org/apache/doris/catalog/Env.java | 10 ++++++++++ .../main/java/org/apache/doris/master/Checkpoint.java | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/DorisFE.java b/fe/fe-core/src/main/java/org/apache/doris/DorisFE.java index 26bfc139df..3a83a25e39 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/DorisFE.java +++ b/fe/fe-core/src/main/java/org/apache/doris/DorisFE.java @@ -172,6 +172,7 @@ public class DorisFE { httpServer.setMinThreads(Config.jetty_threadPool_minThreads); httpServer.setMaxHttpHeaderSize(Config.jetty_server_max_http_header_size); httpServer.start(); + Env.getCurrentEnv().setHttpReady(true); } if (options.enableQeService) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index e853abf798..aefd46d9b4 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -333,6 +333,8 @@ public class Env { // set to true after finished replay all meta and ready to serve // set to false when catalog is not ready. private AtomicBoolean isReady = new AtomicBoolean(false); + // set to true after http server start + private AtomicBoolean httpReady = new AtomicBoolean(false); // set to true if FE can offer READ service. // canRead can be true even if isReady is false. // for example: OBSERVER transfer to UNKNOWN, then isReady will be set to false, but canRead can still be true @@ -920,6 +922,14 @@ public class Env { return isReady.get(); } + public boolean isHttpReady() { + return httpReady.get(); + } + + public void setHttpReady(boolean httpReady) { + this.httpReady.set(httpReady); + } + private void getClusterIdAndRole() throws IOException { File roleFile = new File(this.imageDir, Storage.ROLE_FILE); File versionFile = new File(this.imageDir, Storage.VERSION_FILE); diff --git a/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java b/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java index 2e88084029..94e108f69d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java +++ b/fe/fe-core/src/main/java/org/apache/doris/master/Checkpoint.java @@ -83,6 +83,10 @@ public class Checkpoint extends MasterDaemon { // public for unit test, so that we can trigger checkpoint manually. // DO NOT call it manually outside the unit test. public synchronized void doCheckpoint() throws CheckpointException { + if (!Env.getServingEnv().isHttpReady()) { + LOG.info("Http server is not ready."); + return; + } long imageVersion = 0; long checkPointVersion = 0; Storage storage = null;