From b9664f1fb5405e4cc4491fed584f9d4d414e67a2 Mon Sep 17 00:00:00 2001 From: morningman Date: Sun, 14 Jul 2024 15:28:58 +0800 Subject: [PATCH 1/2] 1 --- .../org/apache/doris/analysis/FunctionCallExpr.java | 1 - .../apache/doris/datasource/ExternalCatalog.java | 5 +++++ .../org/apache/doris/qe/MasterCatalogExecutor.java | 13 +++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index ceb6b037a39fd8..4041fa4873b5be 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -2447,7 +2447,6 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + Objects.hashCode(opcode); result = 31 * result + Objects.hashCode(fnName); - result = 31 * result + Objects.hashCode(fnParams); return result; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java index b643176aaf160a..4ba5a2ebd96281 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java @@ -600,6 +600,11 @@ public void replayInitCatalog(InitCatalogLog log) { // Should not return null. // Because replyInitCatalog can only be called when `use_meta_cache` is false. // And if `use_meta_cache` is false, getDbForReplay() will not return null + if (!db.isPresent()) { + LOG.warn("met invalid db id {} in replayInitCatalog, catalog: {}, ignore it to skip bug.", + log.getRefreshDbIds().get(i), name); + continue; + } Preconditions.checkNotNull(db.get()); tmpDbNameToId.put(db.get().getFullName(), db.get().getId()); tmpIdToDb.put(db.get().getId(), db.get()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java index bb0f5a88e14fdc..27a9fc3d53d512 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java @@ -64,11 +64,20 @@ public void forward(long catalogId, long dbId) throws Exception { boolean isReturnToPool = false; try { TInitExternalCtlMetaResult result = client.initExternalCtlMeta(request); - Env.getCurrentEnv().getJournalObservable().waitOn(result.maxJournalId, waitTimeoutMs); if (!result.getStatus().equalsIgnoreCase(STATUS_OK)) { throw new UserException(result.getStatus()); + }else { + // DO NOT wait on journal replayed, this may cause deadlock. + // 1. hold table read lock + // 2. wait on journal replayed + // 3. previous journal (eg, txn journal) replayed need to hold table write lock + // 4. deadlock + // But no waiting on journal replayed may cause some request on non-master FE failed for some time. + // There is no good solution for this. + // In feature version, this whole process is refactored, so we temporarily remove this waiting. + // Env.getCurrentEnv().getJournalObservable().waitOn(result.maxJournalId, timeoutMs); + isReturnToPool = true; } - isReturnToPool = true; } catch (Exception e) { LOG.warn("Failed to finish forward init operation, please try again. ", e); throw e; From 55200fa645dff84214b6cf38684dcb90394216ac Mon Sep 17 00:00:00 2001 From: morningman Date: Sun, 14 Jul 2024 15:38:40 +0800 Subject: [PATCH 2/2] 1 --- .../main/java/org/apache/doris/qe/MasterCatalogExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java index 27a9fc3d53d512..0fd074451087e3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterCatalogExecutor.java @@ -66,7 +66,7 @@ public void forward(long catalogId, long dbId) throws Exception { TInitExternalCtlMetaResult result = client.initExternalCtlMeta(request); if (!result.getStatus().equalsIgnoreCase(STATUS_OK)) { throw new UserException(result.getStatus()); - }else { + } else { // DO NOT wait on journal replayed, this may cause deadlock. // 1. hold table read lock // 2. wait on journal replayed