You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2023/03/08 02:03:31 UTC
[iotdb] branch master updated: Fix memory calculation is not accurate in SystemInfo (#9237)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 4d8d657a60 Fix memory calculation is not accurate in SystemInfo (#9237)
4d8d657a60 is described below
commit 4d8d657a60af4ff3ec6edc3c7316e35f61019798
Author: Haonan <hh...@outlook.com>
AuthorDate: Wed Mar 8 10:03:24 2023 +0800
Fix memory calculation is not accurate in SystemInfo (#9237)
---
.../main/java/org/apache/iotdb/db/rescon/SystemInfo.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/rescon/SystemInfo.java b/server/src/main/java/org/apache/iotdb/db/rescon/SystemInfo.java
index a355add54e..cad4629046 100644
--- a/server/src/main/java/org/apache/iotdb/db/rescon/SystemInfo.java
+++ b/server/src/main/java/org/apache/iotdb/db/rescon/SystemInfo.java
@@ -74,9 +74,9 @@ public class SystemInfo {
public synchronized boolean reportStorageGroupStatus(
DataRegionInfo dataRegionInfo, TsFileProcessor tsFileProcessor)
throws WriteProcessRejectException {
+ long currentDataRegionMemCost = dataRegionInfo.getMemCost();
long delta =
- dataRegionInfo.getMemCost()
- - reportedStorageGroupMemCostMap.getOrDefault(dataRegionInfo, 0L);
+ currentDataRegionMemCost - reportedStorageGroupMemCostMap.getOrDefault(dataRegionInfo, 0L);
totalStorageGroupMemCost += delta;
if (logger.isDebugEnabled()) {
logger.debug(
@@ -84,8 +84,8 @@ public class SystemInfo {
delta,
totalStorageGroupMemCost);
}
- reportedStorageGroupMemCostMap.put(dataRegionInfo, dataRegionInfo.getMemCost());
- dataRegionInfo.setLastReportedSize(dataRegionInfo.getMemCost());
+ reportedStorageGroupMemCostMap.put(dataRegionInfo, currentDataRegionMemCost);
+ dataRegionInfo.setLastReportedSize(currentDataRegionMemCost);
if (totalStorageGroupMemCost < FLUSH_THERSHOLD) {
return true;
} else if (totalStorageGroupMemCost >= FLUSH_THERSHOLD
@@ -127,15 +127,15 @@ public class SystemInfo {
* @param dataRegionInfo database
*/
public synchronized void resetStorageGroupStatus(DataRegionInfo dataRegionInfo) {
+ long currentDataRegionMemCost = dataRegionInfo.getMemCost();
long delta = 0;
-
if (reportedStorageGroupMemCostMap.containsKey(dataRegionInfo)) {
- delta = reportedStorageGroupMemCostMap.get(dataRegionInfo) - dataRegionInfo.getMemCost();
+ delta = reportedStorageGroupMemCostMap.get(dataRegionInfo) - currentDataRegionMemCost;
this.totalStorageGroupMemCost -= delta;
- dataRegionInfo.setLastReportedSize(dataRegionInfo.getMemCost());
+ dataRegionInfo.setLastReportedSize(currentDataRegionMemCost);
// report after reset sg status, because slow write may not reach the report threshold
dataRegionInfo.setNeedToReportToSystem(true);
- reportedStorageGroupMemCostMap.put(dataRegionInfo, dataRegionInfo.getMemCost());
+ reportedStorageGroupMemCostMap.put(dataRegionInfo, currentDataRegionMemCost);
}
if (totalStorageGroupMemCost >= FLUSH_THERSHOLD