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:40:08 UTC

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

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

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


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

commit 75cf2d31540fd4ca868b7f9967622653add91f35
Author: Alan Choo <43...@users.noreply.github.com>
AuthorDate: Thu Feb 9 16:40:01 2023 +0800

    [To rel/0.13][IOTDB-5426] Cannot trigger flush for sequence file when timed flush enabled (#8986)
---
 .../iotdb/db/engine/storagegroup/StorageGroupInfo.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/StorageGroupInfo.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupInfo.java
index d1a7a752f8..427fcc8721 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupInfo.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupInfo.java
@@ -27,6 +27,7 @@ import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
@@ -48,6 +49,9 @@ public class StorageGroupInfo {
 
   private 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 List<TsFileProcessor> reportedTsps = new CopyOnWriteArrayList<>();
 
@@ -82,13 +86,24 @@ public class StorageGroupInfo {
   }
 
   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 8f3fa6c48e..71050ec1b7 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
@@ -129,6 +129,8 @@ public class SystemInfo {
       delta = reportedStorageGroupMemCostMap.get(storageGroupInfo) - storageGroupInfo.getMemCost();
       this.totalStorageGroupMemCost -= delta;
       storageGroupInfo.setLastReportedSize(storageGroupInfo.getMemCost());
+      // report after reset sg status, because slow write may not reach the report threshold
+      storageGroupInfo.setNeedToReportToSystem(true);
       reportedStorageGroupMemCostMap.put(storageGroupInfo, storageGroupInfo.getMemCost());
     }