Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,6 @@ public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) {
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());
Expand All @@ -1018,8 +1016,6 @@ public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) {
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());
Expand All @@ -1032,10 +1028,6 @@ public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) {
} catch (UserException e) {
// if MTMV has been dropped, ignore this exception
LOG.warn(e);
} finally {
if (mtmv != null) {
mtmv.writeMvUnlock();
}
}
}
}
2 changes: 2 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public void addTaskResult(MTMVTask task, MTMVRelation relation,
}
this.jobInfo.addHistoryTask(task);
this.refreshSnapshot.updateSnapshots(partitionSnapshots, getPartitionNames());
Env.getCurrentEnv().getMtmvService()
.refreshComplete(this, relation, task);
} finally {
writeMvUnlock();
}
Expand Down
20 changes: 10 additions & 10 deletions fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
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;

/**
* 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_";

/**
Expand Down Expand Up @@ -124,16 +128,12 @@ private void setScheduleJobConfig(JobExecutionConfiguration jobExecutionConfigur
*/
@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());
}
}

Expand Down