Skip to content

Commit

Permalink
[opt](plan) only lock olap table when query plan #27639 (#27656)
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman authored Nov 28, 2023
1 parent 1d136d9 commit 43de940
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,17 @@ public boolean isDistributionColumn(String columnName) {
@Override
public boolean isPartitionColumn(String columnName) {
return getPartitionInfo().getPartitionColumns().stream()
.anyMatch(c -> c.getName().equalsIgnoreCase(columnName));
.anyMatch(c -> c.getName().equalsIgnoreCase(columnName));
}

/**
* For olap table, we need to acquire read lock when plan.
* Because we need to make sure the partition's version remain unchanged when plan.
*
* @return
*/
@Override
public boolean needReadLockWhenPlan() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ default int getBaseColumnIdxByName(String colName) {

void write(DataOutput out) throws IOException;

/**
* return true if this kind of table need read lock when doing query plan.
*
* @return
*/
default boolean needReadLockWhenPlan() {
return false;
}

/**
* Doris table type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ public Lock(LogicalPlan plan, CascadesContext cascadesContext) {
cascadesContext.extractTables(plan);
}
for (TableIf table : cascadesContext.tables.values()) {
if (!table.needReadLockWhenPlan()) {
continue;
}
if (!table.tryReadLock(1, TimeUnit.MINUTES)) {
close();
throw new RuntimeException(String.format("Failed to get read lock on table: %s", table.getName()));
Expand Down

0 comments on commit 43de940

Please sign in to comment.