iotdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hao...@apache.org
Subject [iotdb] branch rel/0.12 updated: [IOTDB-1585][To rel/0.12] ModificationFile‘s write interface blocking (#3808)
Date Tue, 24 Aug 2021 01:02:47 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 91b5909  [IOTDB-1585][To rel/0.12] ModificationFile‘s write interface blocking
(#3808)
91b5909 is described below

commit 91b59092ce1883cf21877d4fd8db7d8103151603
Author: Alan Choo <43991780+HeimingZ@users.noreply.github.com>
AuthorDate: Tue Aug 24 09:02:16 2021 +0800

    [IOTDB-1585][To rel/0.12] ModificationFile‘s write interface blocking (#3808)
---
 RELEASE_NOTES.md                                               |  1 +
 .../apache/iotdb/db/engine/modification/ModificationFile.java  | 10 ++++++----
 .../iotdb/db/engine/modification/io/ModificationWriter.java    |  4 ++--
 .../iotdb/db/engine/storagegroup/StorageGroupProcessor.java    | 10 ++--------
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 8ff23c3..ad84276 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -37,6 +37,7 @@
 
 ## Improvements
 * [IOTDB-1566] Do not restrict concurrent write partitions
+* [IOTDB-1585] ModificationFile‘s write interface blocking
 * Use StringCachedPool in TsFileResource to reduce the memory size 
 * write performance optimization when replicaNum == 1
 * Optimize Primitive Array Manager
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
b/server/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
index 43188b6..4b879b2 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
@@ -47,6 +47,7 @@ public class ModificationFile implements AutoCloseable {
   private static final Logger logger = LoggerFactory.getLogger(ModificationFile.class);
   public static final String FILE_SUFFIX = ".mods";
 
+  // lazy loaded, set null when closed
   private List<Modification> modifications;
   private ModificationWriter writer;
   private ModificationReader reader;
@@ -88,8 +89,8 @@ public class ModificationFile implements AutoCloseable {
 
   public void abort() throws IOException {
     synchronized (this) {
-      if (!modifications.isEmpty()) {
-        writer.abort();
+      writer.abort();
+      if (modifications != null && !modifications.isEmpty()) {
         modifications.remove(modifications.size() - 1);
       }
     }
@@ -104,9 +105,10 @@ public class ModificationFile implements AutoCloseable {
    */
   public void write(Modification mod) throws IOException {
     synchronized (this) {
-      checkInit();
       writer.write(mod);
-      modifications.add(mod);
+      if (modifications != null) {
+        modifications.add(mod);
+      }
     }
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/modification/io/ModificationWriter.java
b/server/src/main/java/org/apache/iotdb/db/engine/modification/io/ModificationWriter.java
index 2bef00d..64a5005 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/modification/io/ModificationWriter.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/modification/io/ModificationWriter.java
@@ -31,7 +31,7 @@ public interface ModificationWriter {
 
   /**
    * Write a new modification to the persistent medium. Notice that after calling write(),
a
-   * fileWriter is opened,
+   * fileWriter is opened.
    *
    * @param mod the modification to be written.
    */
@@ -40,6 +40,6 @@ public interface ModificationWriter {
   /** Release resources like streams. */
   void close() throws IOException;
 
-  /** Abort last modification. */
+  /** Abort last modification. Notice that after calling abort(), a fileWriter is opened.
*/
   void abort() throws IOException;
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index ab8ccdc..26f94c0 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -1741,14 +1741,6 @@ public class StorageGroupProcessor {
     try {
       Set<PartialPath> devicePaths = IoTDB.metaManager.getDevices(path.getDevicePath());
       for (PartialPath device : devicePaths) {
-        Long lastUpdateTime = null;
-        for (Map<String, Long> latestTimeMap : latestTimeForEachDevice.values()) {
-          Long curTime = latestTimeMap.get(device.getFullPath());
-          if (curTime != null && (lastUpdateTime == null || lastUpdateTime < curTime))
{
-            lastUpdateTime = curTime;
-          }
-        }
-
         // delete Last cache record if necessary
         tryToDeleteLastCache(device, path, startTime, endTime);
       }
@@ -1771,6 +1763,8 @@ public class StorageGroupProcessor {
       // roll back
       for (ModificationFile modFile : updatedModFiles) {
         modFile.abort();
+        // remember to close mod file
+        modFile.close();
       }
       throw new IOException(e);
     } finally {

Mime
View raw message