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/02/09 08:36:04 UTC

[iotdb] branch rel/1.0 updated: [To rel/1.0][IOTDB-5426] Cannot trigger flush for sequence file when timed flush enabled (#8985)

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

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


The following commit(s) were added to refs/heads/rel/1.0 by this push:
     new b17ca05481 [To rel/1.0][IOTDB-5426] Cannot trigger flush for sequence file when timed flush enabled (#8985)
b17ca05481 is described below

commit b17ca05481f2d82ae0cf23d3bf2a54adc10b7c55
Author: Alan Choo <43...@users.noreply.github.com>
AuthorDate: Thu Feb 9 16:35:57 2023 +0800

    [To rel/1.0][IOTDB-5426] Cannot trigger flush for sequence file when timed flush enabled (#8985)
---
 .../iotdb/db/engine/storagegroup/DataRegionInfo.java    | 17 ++++++++++++++++-
 .../java/org/apache/iotdb/db/rescon/SystemInfo.java     |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegionInfo.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegionInfo.java
index 2add35658e..2f90080c91 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegionInfo.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegionInfo.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.db.rescon.SystemInfo;
 
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
 /** The storageGroupInfo records the total memory cost of the database. */
@@ -45,6 +46,9 @@ public class DataRegionInfo {
 
   private final AtomicLong lastReportedSize = new AtomicLong();
 
+  /** Must report to the system when this value is true */
+  private final AtomicBoolean needToReportToSystem = new AtomicBoolean();
+
   /** A set of all unclosed TsFileProcessors in this SG */
   private final List<TsFileProcessor> reportedTsps = new CopyOnWriteArrayList<>();
 
@@ -79,13 +83,24 @@ public class DataRegionInfo {
   }
 
   public boolean needToReportToSystem() {
-    return memoryCost.get() - lastReportedSize.get() > storageGroupSizeReportThreshold;
+    boolean needToReport =
+        memoryCost.get() - lastReportedSize.get() > storageGroupSizeReportThreshold
+            || needToReportToSystem.get();
+    // report once and then reset flag to false
+    if (needToReportToSystem.get()) {
+      needToReportToSystem.set(false);
+    }
+    return needToReport;
   }
 
   public void setLastReportedSize(long size) {
     lastReportedSize.set(size);
   }
 
+  public void setNeedToReportToSystem(boolean needToReport) {
+    needToReportToSystem.set(needToReport);
+  }
+
   /**
    * When a TsFileProcessor is closing, remove it from reportedTsps, and report to systemInfo to
    * update SG cost.
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 fd0214b519..a355add54e 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
@@ -133,6 +133,8 @@ public class SystemInfo {
       delta = reportedStorageGroupMemCostMap.get(dataRegionInfo) - dataRegionInfo.getMemCost();
       this.totalStorageGroupMemCost -= delta;
       dataRegionInfo.setLastReportedSize(dataRegionInfo.getMemCost());
+      // report after reset sg status, because slow write may not reach the report threshold
+      dataRegionInfo.setNeedToReportToSystem(true);
       reportedStorageGroupMemCostMap.put(dataRegionInfo, dataRegionInfo.getMemCost());
     }