[fix](Nereids) remove db readlock before get table from db (#38660) (#38729)

pick from master #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
This commit is contained in:
morrySnow
2024-08-02 08:34:59 +08:00
committed by GitHub
parent 0da388ade5
commit e140613ae1

View File

@ -552,16 +552,13 @@ public class CascadesContext implements ScheduleContext {
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;
}
/**