Skip to content

Commit

Permalink
Revert "[fix](env) state listener avoid endless waiting #27881 (#41462)…
Browse files Browse the repository at this point in the history
…" (#41669)
  • Loading branch information
w41ter authored Oct 10, 2024
1 parent 9115b64 commit 3593f8b
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 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 @@ -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.
Expand Down Expand Up @@ -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);
}
Expand All @@ -1502,7 +1492,6 @@ public boolean postProcessAfterMetadataReplayed(boolean waitCatalogReady) {

auth.rectifyPrivs();
catalogMgr.registerCatalogRefreshListener(this);
return true;
}

// start all daemon threads only running on Master
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -2588,7 +2574,6 @@ protected synchronized void runOneCycle() {
};

listener.setMetaContext(metaContext);
listener.start();
}

public synchronized boolean replayJournal(long toJournalId) {
Expand Down

0 comments on commit 3593f8b

Please sign in to comment.