caiconghui commented on a change in pull request #6650:
URL: https://github.com/apache/incubator-doris/pull/6650#discussion_r800160997
##########
File path: fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
##########
@@ -415,27 +417,31 @@ private void processReplaceTable(Database db, OlapTable
origTable, List<AlterCla
ReplaceTableClause clause = (ReplaceTableClause) alterClauses.get(0);
String newTblName = clause.getTblName();
boolean swapTable = clause.isSwapTable();
- Table newTbl = db.getTableOrMetaException(newTblName, TableType.OLAP);
- OlapTable olapNewTbl = (OlapTable) newTbl;
- db.writeLock();
- origTable.writeLock();
+ db.writeLockOrDdlException();
try {
- String oldTblName = origTable.getName();
- // First, we need to check whether the table to be operated on can
be renamed
- olapNewTbl.checkAndSetName(oldTblName, true);
- if (swapTable) {
- origTable.checkAndSetName(newTblName, true);
+ Table newTbl = db.getTableOrMetaException(newTblName,
TableType.OLAP);
+ OlapTable olapNewTbl = (OlapTable) newTbl;
+ List<Table> tableList = Lists.newArrayList(origTable, newTbl);
+ tableList.sort((Comparator.comparing(Table::getId)));
+ MetaLockUtils.writeLockTables(tableList);
Review comment:
fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]