Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature](mtmv)after creating a materialized view, if other operations fail, roll back #28621

Merged
merged 3 commits into from
Dec 19, 2023
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
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 @@ -2590,7 +2592,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
Loading