Skip to content

Commit

Permalink
[fix](Nereids) remove db readlock before get table from db (apache#38660
Browse files Browse the repository at this point in the history
) (apache#38729)

pick from master apache#38660

insert will hold readlock of target table before planning. if nereids
need db readlock after it, will lead to dead lock. because other
statement need to hold db lock before get table lock

for example:

insert: target table read lock -> database read lock
drop table: database write lock -> target table write lock
  • Loading branch information
morrySnow authored and morningman committed Aug 2, 2024
1 parent 9770c5c commit fb4680c
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -552,16 +552,13 @@ public TableIf getTable(String ctlName, String dbName, String tableName, Env env
if (db == null) {
throw new RuntimeException("Database [" + dbName + "] does not exist in catalog [" + ctlName + "].");
}
db.readLock();
try {
TableIf table = db.getTableNullable(tableName);
if (table == null) {
throw new RuntimeException("Table [" + tableName + "] does not exist in database [" + dbName + "].");
}
return table;
} finally {
db.readUnlock();

TableIf table = db.getTableNullable(tableName);
if (table == null) {
throw new RuntimeException("Table [" + tableName + "] does not exist in database [" + dbName + "].");
}
return table;

}

/**
Expand Down

0 comments on commit fb4680c

Please sign in to comment.