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 52ddf6357a [IOTDB-5426] Cannot trigger flush for sequence file when
timed flush enabled (#8938)
52ddf6357a is described below
commit 52ddf6357aee45d5b93c7a7e7d36b5cd1dad7b0d
Author: Alan Choo <[email protected]>
AuthorDate: Mon Feb 6 09:41:34 2023 +0800
[IOTDB-5426] Cannot trigger flush for sequence file when timed flush
enabled (#8938)
---
.../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());
}