Skip to content

Commit

Permalink
fix unit test failed for AlterTest
Browse files Browse the repository at this point in the history
  • Loading branch information
caiconghui [蔡聪辉] committed Sep 24, 2020
1 parent 9b253dc commit 5c76212
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,26 @@ public void processAlterTable(AlterTableStmt stmt) throws UserException {
if (db == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_BAD_DB_ERROR, dbName);
}
List<AlterClause> alterClauses;

// some operations will take long time to process, need to be done outside the databse lock
boolean needProcessOutsideDatabaseLock = false;
// check conflict alter ops first
alterClauses = stmt.getOps();
AlterOperations currentAlterOps = new AlterOperations();
currentAlterOps.checkConflict(alterClauses);

// check cluster capacity and db quota, only need to check once.
currentAlterOps.checkConflict(stmt.getOps());
// check cluster capacity and db quota outside table lock to escape dead lock, only need to check once.
if (currentAlterOps.needCheckCapacity()) {
Catalog.getCurrentSystemInfo().checkClusterCapacity(clusterName);
db.checkQuota();
}

List<AlterClause> alterClauses;
String tableName = dbTableName.getTbl();
OlapTable olapTable = (OlapTable) db.getTableOrThrowException(tableName, TableType.OLAP);
olapTable.writeLock();
try {
stmt.rewriteAlterClause(olapTable);
alterClauses = stmt.getOps();
currentAlterOps = new AlterOperations();
currentAlterOps.checkConflict(alterClauses);
if (olapTable.getState() != OlapTableState.NORMAL) {
throw new DdlException(
"Table[" + olapTable.getName() + "]'s state is not NORMAL. Do not allow doing ALTER ops");
Expand Down Expand Up @@ -337,14 +337,14 @@ private void processRename(Database db, OlapTable table, List<AlterClause> alter

/**
* Batch update partitions' properties
* caller should hold the db lock
* caller should hold the table lock
*/
public void modifyPartitionsProperty(Database db,
OlapTable olapTable,
List<String> partitionNames,
Map<String, String> properties)
throws DdlException, AnalysisException {
Preconditions.checkArgument(db.isWriteLockHeldByCurrentThread());
Preconditions.checkArgument(olapTable.isWriteLockHeldByCurrentThread());
List<ModifyPartitionInfo> modifyPartitionInfos = Lists.newArrayList();
if (olapTable.getState() != OlapTableState.NORMAL) {
throw new DdlException("Table[" + olapTable.getName() + "]'s state is not NORMAL");
Expand Down Expand Up @@ -417,7 +417,7 @@ public ModifyPartitionInfo modifyPartitionProperty(Database db,
String partitionName,
Map<String, String> properties)
throws DdlException {
Preconditions.checkArgument(db.isWriteLockHeldByCurrentThread());
Preconditions.checkArgument(olapTable.isWriteLockHeldByCurrentThread());
if (olapTable.getState() != OlapTableState.NORMAL) {
throw new DdlException("Table[" + olapTable.getName() + "]'s state is not NORMAL");
}
Expand Down

0 comments on commit 5c76212

Please sign in to comment.