From 6843cce7025292d4174996a3fcadc4fd1f03ff72 Mon Sep 17 00:00:00 2001 From: meiyi Date: Sat, 27 Dec 2025 01:59:36 +0800 Subject: [PATCH] [fix](fe) modify tablet cooldownConfLock to reduce memory (#59356) ### What problem does this PR solve? the usage of `cooldownConfLock` is simple, does not need ReentrantReadWriteLock because it cost too much memory, especially when a cluster has many tablets. before: 1 after: 2 --- .../java/org/apache/doris/catalog/Tablet.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java index 379cc0a17da716..0a07ffe82d3865 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java @@ -25,7 +25,6 @@ import org.apache.doris.common.FeConstants; import org.apache.doris.common.Pair; import org.apache.doris.common.UserException; -import org.apache.doris.common.lock.MonitoredReentrantReadWriteLock; import org.apache.doris.resource.Tag; import org.apache.doris.system.Backend; import org.apache.doris.system.SystemInfoService; @@ -123,7 +122,7 @@ public TabletHealth() { private long cooldownReplicaId = -1; @SerializedName(value = "ctm", alternate = {"cooldownTerm"}) private long cooldownTerm = -1; - private MonitoredReentrantReadWriteLock cooldownConfLock = new MonitoredReentrantReadWriteLock(); + private final Object cooldownConfLock = new Object(); // last time that the tablet checker checks this tablet. // no need to persist @@ -184,10 +183,10 @@ public boolean isConsistent() { } public void setCooldownConf(long cooldownReplicaId, long cooldownTerm) { - cooldownConfLock.writeLock().lock(); - this.cooldownReplicaId = cooldownReplicaId; - this.cooldownTerm = cooldownTerm; - cooldownConfLock.writeLock().unlock(); + synchronized (cooldownConfLock) { + this.cooldownReplicaId = cooldownReplicaId; + this.cooldownTerm = cooldownTerm; + } } public long getCooldownReplicaId() { @@ -195,11 +194,8 @@ public long getCooldownReplicaId() { } public Pair getCooldownConf() { - cooldownConfLock.readLock().lock(); - try { + synchronized (cooldownConfLock) { return Pair.of(cooldownReplicaId, cooldownTerm); - } finally { - cooldownConfLock.readLock().unlock(); } }