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 f7148d45390a72..dd65fa7cafd9c4 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 @@ -925,7 +925,8 @@ public void initialize(String[] args) throws Exception { createTxnCleaner(); // 6. start state listener thread - startStateListener(); + createStateListener(); + listener.start(); if (!Config.edit_log_type.equalsIgnoreCase("bdb")) { // If not using bdb, we need to notify the FE type transfer manually. @@ -1478,22 +1479,11 @@ void advanceNextId() { * 2. register some hook. * If there is, add them here. */ - public boolean postProcessAfterMetadataReplayed(boolean waitCatalogReady) { + public void postProcessAfterMetadataReplayed(boolean waitCatalogReady) { if (waitCatalogReady) { while (!isReady()) { - // Avoid endless waiting if the state has changed. - // - // Consider the following situation: - // 1. The follower replay journals and is not set to ready because the synchronization internval - // exceeds meta delay toleration seconds. - // 2. The underlying BEBJE node of this follower is selected as the master, but the state listener - // thread is waiting for catalog ready. - if (typeTransferQueue.peek() != null) { - return false; - } - try { - Thread.sleep(100); + Thread.sleep(10 * 1000); } catch (InterruptedException e) { LOG.warn("", e); } @@ -1502,7 +1492,6 @@ public boolean postProcessAfterMetadataReplayed(boolean waitCatalogReady) { auth.rectifyPrivs(); catalogMgr.registerCatalogRefreshListener(this); - return true; } // start all daemon threads only running on Master @@ -1620,10 +1609,7 @@ private void transferToNonMaster(FrontendNodeType newType) { } // 'isReady' will be set to true in 'setCanRead()' method - if (!postProcessAfterMetadataReplayed(true)) { - // the state has changed, exit early. - return; - } + postProcessAfterMetadataReplayed(true); checkLowerCaseTableNames(); @@ -2480,7 +2466,7 @@ public void notifyNewFETypeTransfer(FrontendNodeType newType) { } } - public void startStateListener() { + public void createStateListener() { listener = new Daemon("stateListener", STATE_CHANGE_CHECK_INTERVAL_MS) { @Override protected synchronized void runOneCycle() { @@ -2588,7 +2574,6 @@ protected synchronized void runOneCycle() { }; listener.setMetaContext(metaContext); - listener.start(); } public synchronized boolean replayJournal(long toJournalId) {