[fix](MTMV) fix replayReplaceTable error when restart fe (#15564)
This commit is contained in:
@ -542,8 +542,9 @@ public class Alter {
|
||||
long newTblId = log.getNewTblId();
|
||||
|
||||
Database db = Env.getCurrentInternalCatalog().getDbOrMetaException(dbId);
|
||||
OlapTable origTable = (OlapTable) db.getTableOrMetaException(origTblId, TableType.OLAP);
|
||||
OlapTable newTbl = (OlapTable) db.getTableOrMetaException(newTblId, TableType.OLAP);
|
||||
List<TableType> tableTypes = Lists.newArrayList(TableType.OLAP, TableType.MATERIALIZED_VIEW);
|
||||
OlapTable origTable = (OlapTable) db.getTableOrMetaException(origTblId, tableTypes);
|
||||
OlapTable newTbl = (OlapTable) db.getTableOrMetaException(newTblId, tableTypes);
|
||||
List<Table> tableList = Lists.newArrayList(origTable, newTbl);
|
||||
tableList.sort((Comparator.comparing(Table::getId)));
|
||||
MetaLockUtils.writeLockTablesOrMetaException(tableList);
|
||||
|
||||
@ -181,6 +181,16 @@ public interface DatabaseIf<T extends TableIf> {
|
||||
return table;
|
||||
}
|
||||
|
||||
default T getTableOrMetaException(long tableId, List<TableIf.TableType> tableTypes)
|
||||
throws MetaNotFoundException {
|
||||
T table = getTableOrMetaException(tableId);
|
||||
if (!tableTypes.contains(table.getType())) {
|
||||
throw new MetaNotFoundException(
|
||||
"Tye type of " + tableId + " doesn't match, expected data tables=" + tableTypes);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
default T getTableOrDdlException(String tableName) throws DdlException {
|
||||
return getTableOrException(tableName, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user