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 e6a2fe0229f0a8..1be7dff797edc8 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 @@ -1014,7 +1014,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 b0d25ad2b252b2..955bfd4279fd5c 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 @@ -190,15 +190,19 @@ 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() && !Config.enable_check_compatibility_mode) { 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);