This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new c487fc0e5ff [enhance](mtmv)Optimize the logic of mtmv lock (#41010) (#41254) c487fc0e5ff is described below commit c487fc0e5ff7264c7b379a4cd15001e61ea5bdd3 Author: zhangdong <493738...@qq.com> AuthorDate: Thu Sep 26 23:02:02 2024 +0800 [enhance](mtmv)Optimize the logic of mtmv lock (#41010) (#41254) pick: https://github.com/apache/doris/pull/41010 --- .../src/main/java/org/apache/doris/alter/Alter.java | 8 -------- .../src/main/java/org/apache/doris/catalog/MTMV.java | 2 ++ .../java/org/apache/doris/mtmv/MTMVJobManager.java | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 18 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 ac8ff78c6ce..390c994a645 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 @@ -947,8 +947,6 @@ public class Alter { try { Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(tbl.getDb()); mtmv = (MTMV) db.getTableOrMetaException(tbl.getTbl(), TableType.MATERIALIZED_VIEW); - - mtmv.writeMvLock(); switch (alterMTMV.getOpType()) { case ALTER_REFRESH_INFO: mtmv.alterRefreshInfo(alterMTMV.getRefreshInfo()); @@ -961,8 +959,6 @@ public class Alter { break; case ADD_TASK: mtmv.addTaskResult(alterMTMV.getTask(), alterMTMV.getRelation(), alterMTMV.getPartitionSnapshots()); - Env.getCurrentEnv().getMtmvService() - .refreshComplete(mtmv, alterMTMV.getRelation(), alterMTMV.getTask()); break; default: throw new RuntimeException("Unknown type value: " + alterMTMV.getOpType()); @@ -975,10 +971,6 @@ public class Alter { } catch (UserException e) { // if MTMV has been dropped, ignore this exception LOG.warn(e); - } finally { - if (mtmv != null) { - mtmv.writeMvUnlock(); - } } } } 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 251760ad614..109fcf96281 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 @@ -210,6 +210,8 @@ public class MTMV extends OlapTable { } this.jobInfo.addHistoryTask(task); this.refreshSnapshot.updateSnapshots(partitionSnapshots, getPartitionNames()); + Env.getCurrentEnv().getMtmvService() + .refreshComplete(this, relation, task); } finally { writeMvUnlock(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java index 1ace738f1d0..8ffcea423d7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java @@ -48,6 +48,8 @@ import org.apache.doris.qe.ConnectContext; import com.google.common.collect.Lists; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.List; @@ -55,6 +57,8 @@ import java.util.List; * when do some operation, do something about job */ public class MTMVJobManager implements MTMVHookService { + private static final Logger LOG = LogManager.getLogger(MTMVJobManager.class); + public static final String MTMV_JOB_PREFIX = "inner_mtmv_"; /** @@ -124,16 +128,12 @@ public class MTMVJobManager implements MTMVHookService { */ @Override public void dropMTMV(MTMV mtmv) throws DdlException { - List<MTMVJob> jobs = Env.getCurrentEnv().getJobManager() - .queryJobs(JobType.MV, mtmv.getJobInfo().getJobName()); - if (!CollectionUtils.isEmpty(jobs)) { - try { - Env.getCurrentEnv().getJobManager() - .unregisterJob(jobs.get(0).getJobId()); - } catch (JobException e) { - e.printStackTrace(); - throw new DdlException(e.getMessage()); - } + try { + Env.getCurrentEnv().getJobManager() + .unregisterJob(mtmv.getJobInfo().getJobName(), false); + } catch (JobException e) { + LOG.warn("drop mtmv job failed, mtmvName: {}", mtmv.getName(), e); + throw new DdlException(e.getMessage()); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org