pick: https://github.com/apache/doris/pull/41010
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user