From 9e0ece24523bcb1f406cd69661d6c1e9a0060bac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:06:07 +0800 Subject: [PATCH] branch-2.1: [enhance](mtmv)MTMV no longer generate cache when replaying logs #44283 (#44308) Cherry-picked from #44283 Co-authored-by: zhangdong --- .../src/main/java/org/apache/doris/alter/Alter.java | 3 ++- .../src/main/java/org/apache/doris/catalog/MTMV.java | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java index 52b6934c3a3f6a..44b83f8065436f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java @@ -957,7 +957,8 @@ public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) { mtmv.alterMvProperties(alterMTMV.getMvProperties()); break; case ADD_TASK: - mtmv.addTaskResult(alterMTMV.getTask(), alterMTMV.getRelation(), alterMTMV.getPartitionSnapshots()); + mtmv.addTaskResult(alterMTMV.getTask(), alterMTMV.getRelation(), alterMTMV.getPartitionSnapshots(), + isReplay); break; default: throw new RuntimeException("Unknown type value: " + alterMTMV.getOpType()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java index 80d7f48a9eec4b..700a1364fdb25d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java @@ -188,14 +188,18 @@ public MTMVStatus alterStatus(MTMVStatus newStatus) { } public void addTaskResult(MTMVTask task, MTMVRelation relation, - Map partitionSnapshots) { + Map partitionSnapshots, boolean isReplay) { MTMVCache mtmvCache = null; boolean needUpdateCache = false; if (task.getStatus() == TaskStatus.SUCCESS && !Env.isCheckpointThread()) { needUpdateCache = true; try { - // shouldn't do this while holding mvWriteLock - mtmvCache = MTMVCache.from(this, MTMVPlanUtil.createMTMVContext(this), true); + // The replay thread may not have initialized the catalog yet to avoid getting stuck due + // to connection issues such as S3, so it is directly set to null + if (!isReplay) { + // shouldn't do this while holding mvWriteLock + mtmvCache = MTMVCache.from(this, MTMVPlanUtil.createMTMVContext(this), true); + } } catch (Throwable e) { mtmvCache = null; LOG.warn("generate cache failed", e);