(selectdb-cloud) Reduce FE db lock range for ShowDataStmt (#26588)

Reduce read lock critical sections and avoid execution timeouts
This commit is contained in:
walter
2023-11-08 22:24:17 +08:00
committed by GitHub
parent b7a2c2e9c4
commit 8e332fa979

View File

@ -274,24 +274,23 @@ public class Database extends MetaObject implements Writable, DatabaseIf<Table>
public long getUsedDataQuotaWithLock() {
long usedDataQuota = 0;
readLock();
try {
for (Table table : this.idToTable.values()) {
if (table.getType() != TableType.OLAP) {
continue;
}
List<Table> tables = new ArrayList<>(this.idToTable.values());
readUnlock();
OlapTable olapTable = (OlapTable) table;
olapTable.readLock();
try {
usedDataQuota = usedDataQuota + olapTable.getDataSize();
} finally {
olapTable.readUnlock();
}
for (Table table : tables) {
if (table.getType() != TableType.OLAP) {
continue;
}
OlapTable olapTable = (OlapTable) table;
olapTable.readLock();
try {
usedDataQuota = usedDataQuota + olapTable.getDataSize();
} finally {
olapTable.readUnlock();
}
return usedDataQuota;
} finally {
readUnlock();
}
return usedDataQuota;
}
public long getReplicaCountWithLock() {