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 00:42:07 UTC

[iotdb] branch fix_mem_control created (now f4db3dca09)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a change to branch fix_mem_control
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at f4db3dca09 Fix memory calculatation is not accurate in SystemInfo

This branch includes the following new commits:

     new f4db3dca09 Fix memory calculatation is not accurate in SystemInfo

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: Fix memory calculatation is not accurate in SystemInfo

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch fix_mem_control
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit f4db3dca09ac4a3560fa570e0669f7a571c2777e
Author: HTHou <hh...@outlook.com>
AuthorDate: Wed Mar 8 08:41:35 2023 +0800

    Fix memory calculatation is not accurate in SystemInfo
---
 .../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..6ed7a54172 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 currentDataRegionInfo = dataRegionInfo.getMemCost();
     long delta =
-        dataRegionInfo.getMemCost()
-            - reportedStorageGroupMemCostMap.getOrDefault(dataRegionInfo, 0L);
+        currentDataRegionInfo - 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, currentDataRegionInfo);
+    dataRegionInfo.setLastReportedSize(currentDataRegionInfo);
     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 currentDataRegionInfo = dataRegionInfo.getMemCost();
     long delta = 0;
-
     if (reportedStorageGroupMemCostMap.containsKey(dataRegionInfo)) {
-      delta = reportedStorageGroupMemCostMap.get(dataRegionInfo) - dataRegionInfo.getMemCost();
+      delta = reportedStorageGroupMemCostMap.get(dataRegionInfo) - currentDataRegionInfo;
       this.totalStorageGroupMemCost -= delta;
-      dataRegionInfo.setLastReportedSize(dataRegionInfo.getMemCost());
+      dataRegionInfo.setLastReportedSize(currentDataRegionInfo);
       // 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, currentDataRegionInfo);
     }
 
     if (totalStorageGroupMemCost >= FLUSH_THERSHOLD