[fix](MTMV) fix replayReplaceTable error when restart fe (#15564)

This commit is contained in:
chenlinzhong
2023-01-10 11:36:17 +08:00
committed by GitHub
parent 025623a124
commit 1888aba301
2 changed files with 13 additions and 2 deletions

View File

@ -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);

View File

@ -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)));
}