This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 6f20cac1da [bugfix](cooldown) Fix potential deadlock while calling handleCooldownConf (#20975) 6f20cac1da is described below commit 6f20cac1da20561479c9353bc4f6dd69b16d2f9b Author: plat1ko <platonekos...@gmail.com> AuthorDate: Wed Jun 21 14:44:01 2023 +0800 [bugfix](cooldown) Fix potential deadlock while calling handleCooldownConf (#20975) --- .../apache/doris/catalog/TabletInvertedIndex.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java index 4bf06c4e4d..ece6ebd8b5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java @@ -129,6 +129,7 @@ public class TabletInvertedIndex { List<TTabletMetaInfo> tabletToUpdate, List<CooldownConf> cooldownConfToPush, List<CooldownConf> cooldownConfToUpdate) { + List<Pair<TabletMeta, TTabletInfo>> cooldownTablets = new ArrayList<>(); long stamp = readLock(); long start = System.currentTimeMillis(); try { @@ -198,8 +199,11 @@ public class TabletInvertedIndex { } if (Config.enable_storage_policy && backendTabletInfo.isSetCooldownTerm()) { - handleCooldownConf(tabletMeta, backendTabletInfo, cooldownConfToPush, - cooldownConfToUpdate); + // Place tablet info in a container and process it outside of read lock to avoid + // deadlock with OlapTable lock + synchronized (cooldownTablets) { + cooldownTablets.add(Pair.of(tabletMeta, backendTabletInfo)); + } replica.setCooldownMetaId(backendTabletInfo.getCooldownMetaId()); replica.setCooldownTerm(backendTabletInfo.getCooldownTerm()); } @@ -326,6 +330,7 @@ public class TabletInvertedIndex { } finally { readUnlock(stamp); } + cooldownTablets.forEach(p -> handleCooldownConf(p.first, p.second, cooldownConfToPush, cooldownConfToUpdate)); long end = System.currentTimeMillis(); LOG.info("finished to do tablet diff with backend[{}]. sync: {}." @@ -422,9 +427,7 @@ public class TabletInvertedIndex { if (cooldownConf.first <= 0) { // invalid cooldownReplicaId CooldownConf conf = new CooldownConf(tabletMeta.getDbId(), tabletMeta.getTableId(), tabletMeta.getPartitionId(), tabletMeta.getIndexId(), beTabletInfo.tablet_id, cooldownConf.second); - synchronized (cooldownConfToUpdate) { - cooldownConfToUpdate.add(conf); - } + cooldownConfToUpdate.add(conf); return; } @@ -445,17 +448,13 @@ public class TabletInvertedIndex { if (!replicaAlive) { CooldownConf conf = new CooldownConf(tabletMeta.getDbId(), tabletMeta.getTableId(), tabletMeta.getPartitionId(), tabletMeta.getIndexId(), beTabletInfo.tablet_id, cooldownConf.second); - synchronized (cooldownConfToUpdate) { - cooldownConfToUpdate.add(conf); - } + cooldownConfToUpdate.add(conf); return; } if (beTabletInfo.getCooldownTerm() < cooldownConf.second) { CooldownConf conf = new CooldownConf(beTabletInfo.tablet_id, cooldownConf.first, cooldownConf.second); - synchronized (cooldownConfToPush) { - cooldownConfToPush.add(conf); - } + cooldownConfToPush.add(conf); return; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org