Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Sep 9, 2024
1 parent 7adfbf8 commit 3a1bfb2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
1 change: 1 addition & 0 deletions be/src/cloud/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

#include "cloud/config.h"
#include "common/status.h"

namespace doris::config {

Expand Down
7 changes: 7 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,13 @@ public void setHttpReady(boolean httpReady) {
this.httpReady.set(httpReady);
}

protected boolean isStartFromEmpty() {
File roleFile = new File(this.imageDir, Storage.ROLE_FILE);
File versionFile = new File(this.imageDir, Storage.VERSION_FILE);

return !roleFile.exists() && !versionFile.exists();
}

protected void getClusterIdAndRole() throws IOException {
File roleFile = new File(this.imageDir, Storage.ROLE_FILE);
File versionFile = new File(this.imageDir, Storage.VERSION_FILE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ private Cloud.NodeInfoPB getLocalTypeFromMetaService() {
return local.orElse(null);
}

private void tryAddMyselToMS() {
try {
try {
if (Strings.isNullOrEmpty(Config.cloud_instance_id)) {
throw new DdlException("unable to create instance due to empty cloud_instance_id");
}
getCloudSystemInfoService().tryCreateInstance(Config.cloud_instance_id,
Config.cloud_instance_id, false);
} catch (Exception e) {
return;
}
addFrontend(FrontendNodeType.MASTER, selfNode.getHost(), selfNode.getPort());
} catch (DdlException e) {
LOG.warn("get ddl exception ", e);
}
}

protected void getClusterIdAndRole() throws IOException {
NodeInfoPB.NodeType type = NodeInfoPB.NodeType.UNKNOWN;
Expand All @@ -202,22 +218,13 @@ protected void getClusterIdAndRole() throws IOException {
if (nodeInfoPB == null) {
LOG.warn("failed to get local fe's type, sleep {} s, try again.",
Config.resource_not_ready_sleep_seconds);
if (isStartFromEmpty()) {
tryAddMyselToMS();
}
try {
try {
if (Strings.isNullOrEmpty(Config.cloud_instance_id)) {
throw new DdlException("unable to create instance due to empty cloud_instance_id");
}
getCloudSystemInfoService().tryCreateInstance(Config.cloud_instance_id,
Config.cloud_instance_id, false);
} catch (Exception e) {
Thread.sleep(Config.resource_not_ready_sleep_seconds);
throw e;
}
addFrontend(FrontendNodeType.MASTER, selfNode.getHost(), selfNode.getPort());
Thread.sleep(Config.resource_not_ready_sleep_seconds);
} catch (InterruptedException e) {
LOG.warn("thread sleep Exception", e);
} catch (DdlException e) {
LOG.warn("get ddl exception ", e);
LOG.info("interrupted by {}", e);
}
continue;
}
Expand Down

0 comments on commit 3a1bfb2

Please sign in to comment.