From 4bc5050dd86482e20437f2528972fbf125e13283 Mon Sep 17 00:00:00 2001 From: walter Date: Wed, 8 Nov 2023 22:24:17 +0800 Subject: [PATCH] (selectdb-cloud) Reduce FE db lock range for ShowDataStmt (#26588) Reduce read lock critical sections and avoid execution timeouts --- .../org/apache/doris/catalog/Database.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java index 74b8608760c86b..62d2e0bd6d6e56 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java @@ -274,24 +274,23 @@ public void setDbProperties(DatabaseProperty dbProperties) { public long getUsedDataQuotaWithLock() { long usedDataQuota = 0; readLock(); - try { - for (Table table : this.idToTable.values()) { - if (table.getType() != TableType.OLAP) { - continue; - } + List 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() {