Skip to content

Commit

Permalink
[feature](mtmv)after creating a materialized view, if other operation…
Browse files Browse the repository at this point in the history
…s fail, roll back (apache#28621)

after create mtmv, if create job failed,need drop mtmv
  • Loading branch information
zddr authored Dec 19, 2023
1 parent 1111854 commit a871409
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
import org.apache.doris.datasource.hive.HMSCachedClientFactory;
import org.apache.doris.datasource.property.constants.HMSProperties;
import org.apache.doris.external.elasticsearch.EsRepository;
import org.apache.doris.nereids.trees.plans.commands.info.DropMTMVInfo;
import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
import org.apache.doris.persist.AlterDatabasePropertyInfo;
import org.apache.doris.persist.AutoIncrementIdUpdateLog;
import org.apache.doris.persist.ColocatePersistInfo;
Expand Down Expand Up @@ -2591,7 +2593,20 @@ private void createOlapTable(Database db, CreateTableStmt stmt) throws UserExcep
throw e;
}
if (olapTable instanceof MTMV) {
Env.getCurrentEnv().getMtmvService().createMTMV((MTMV) olapTable);
try {
Env.getCurrentEnv().getMtmvService().createMTMV((MTMV) olapTable);
} catch (Throwable t) {
LOG.warn("create mv failed, start rollback, error msg: " + t.getMessage());
try {
DropMTMVInfo dropMTMVInfo = new DropMTMVInfo(
new TableNameInfo(olapTable.getDatabase().getFullName(), olapTable.getName()), true);
Env.getCurrentEnv().dropTable(dropMTMVInfo.translateToLegacyStmt());
} catch (Throwable throwable) {
LOG.warn("rollback mv failed, please drop mv by manual, error msg: " + t.getMessage());
}
throw t;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private static boolean isSync(long visibleVersionTime, Set<BaseTableInfo> tables
try {
table = getTable(baseTableInfo);
} catch (AnalysisException e) {
e.printStackTrace();
LOG.warn("get table failed, {}", baseTableInfo, e);
return false;
}
if (excludedTriggerTables.contains(table.getName())) {
Expand Down

0 comments on commit a871409

Please sign in to comment.