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:06:36 UTC

[iotdb] branch fix_mem_control_11 created (now 43d0925eab)

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

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


      at 43d0925eab Fix memory calculation is not accurate in SystemInfo (#9237)

This branch includes the following new commits:

     new 43d0925eab Fix memory calculation is not accurate in SystemInfo (#9237)

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 calculation is not accurate in SystemInfo (#9237)

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_11
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 43d0925eab49ad041891b0cae6d543327034059f
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