Skip to content

Commit 66a7d11

Browse files
authored
[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: <img width="1280" height="575" alt="1" src="https://github.com/user-attachments/assets/df626e1e-84ef-4078-8da7-d857ac960678" /> after: <img width="1280" height="510" alt="2" src="https://github.com/user-attachments/assets/3fee7407-0743-4d07-9462-a9f0e101765f" />
1 parent 1f6d752 commit 66a7d11

File tree

1 file changed

+6
-10
lines changed
  • fe/fe-core/src/main/java/org/apache/doris/catalog

1 file changed

+6
-10
lines changed

fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.doris.common.FeConstants;
2626
import org.apache.doris.common.Pair;
2727
import org.apache.doris.common.UserException;
28-
import org.apache.doris.common.lock.MonitoredReentrantReadWriteLock;
2928
import org.apache.doris.resource.Tag;
3029
import org.apache.doris.system.Backend;
3130
import org.apache.doris.system.SystemInfoService;
@@ -123,7 +122,7 @@ public TabletHealth() {
123122
private long cooldownReplicaId = -1;
124123
@SerializedName(value = "ctm", alternate = {"cooldownTerm"})
125124
private long cooldownTerm = -1;
126-
private MonitoredReentrantReadWriteLock cooldownConfLock = new MonitoredReentrantReadWriteLock();
125+
private final Object cooldownConfLock = new Object();
127126

128127
// last time that the tablet checker checks this tablet.
129128
// no need to persist
@@ -184,22 +183,19 @@ public boolean isConsistent() {
184183
}
185184

186185
public void setCooldownConf(long cooldownReplicaId, long cooldownTerm) {
187-
cooldownConfLock.writeLock().lock();
188-
this.cooldownReplicaId = cooldownReplicaId;
189-
this.cooldownTerm = cooldownTerm;
190-
cooldownConfLock.writeLock().unlock();
186+
synchronized (cooldownConfLock) {
187+
this.cooldownReplicaId = cooldownReplicaId;
188+
this.cooldownTerm = cooldownTerm;
189+
}
191190
}
192191

193192
public long getCooldownReplicaId() {
194193
return cooldownReplicaId;
195194
}
196195

197196
public Pair<Long, Long> getCooldownConf() {
198-
cooldownConfLock.readLock().lock();
199-
try {
197+
synchronized (cooldownConfLock) {
200198
return Pair.of(cooldownReplicaId, cooldownTerm);
201-
} finally {
202-
cooldownConfLock.readLock().unlock();
203199
}
204200
}
205201

0 commit comments

Comments
 (0)