You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/06/05 09:50:38 UTC

[incubator-iotdb] branch fix_partial_insert_bug created (now f6d507d)

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

qiaojialin pushed a change to branch fix_partial_insert_bug
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at f6d507d  fix partial write and async close bug

This branch includes the following new commits:

     new f6d507d  fix partial write and async close bug

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.



[incubator-iotdb] 01/01: fix partial write and async close bug

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch fix_partial_insert_bug
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit f6d507da015e733dc3c8e07cbdd7c9bce506e52b
Author: qiaojialin <64...@qq.com>
AuthorDate: Fri Jun 5 17:50:15 2020 +0800

    fix partial write and async close bug
---
 .../iotdb/db/engine/memtable/AbstractMemTable.java |  5 +++-
 .../db/engine/storagegroup/TsFileProcessor.java    |  4 ++-
 .../iotdb/db/integration/IoTDBSimpleQueryIT.java   | 33 +++++++++++++++++++++-
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java b/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
index 4629023..73ece8b 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
@@ -111,7 +111,7 @@ public abstract class AbstractMemTable implements IMemTable {
           insertPlan.getSchemas()[i], insertPlan.getTime(), value);
     }
 
-    totalPointsNum += insertPlan.getValues().length;
+    totalPointsNum += insertPlan.getValues().length - insertPlan.getFailedMeasurements().size();
   }
 
   @Override
@@ -171,6 +171,9 @@ public abstract class AbstractMemTable implements IMemTable {
 
   @Override
   public boolean reachTotalPointNumThreshold() {
+    if (totalPointsNum == 0) {
+      return false;
+    }
     return totalPointsNum >= totalPointsNumThreshold;
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
index 31c76f2..6d90ed8 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
@@ -378,7 +378,9 @@ public class TsFileProcessor {
 
       //we have to add the memtable into flushingList first and then set the shouldClose tag.
       // see https://issues.apache.org/jira/browse/IOTDB-510
-      IMemTable tmpMemTable = workMemTable == null ? new NotifyFlushMemTable() : workMemTable;
+      IMemTable tmpMemTable = workMemTable == null || workMemTable.memSize() == 0
+          ? new NotifyFlushMemTable()
+          : workMemTable;
 
       try {
         addAMemtableIntoFlushingList(tmpMemTable);
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
index a4deafc..05bfd78 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSimpleQueryIT.java
@@ -27,6 +27,7 @@ import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.jdbc.Config;
 import org.apache.iotdb.jdbc.IoTDBSQLException;
@@ -183,7 +184,6 @@ public class IoTDBSimpleQueryIT {
       statement.execute("CREATE TIMESERIES root.sg1.d0.s0 WITH DATATYPE=INT32,ENCODING=PLAIN");
       statement.execute("CREATE TIMESERIES root.sg1.d0.s1 WITH DATATYPE=INT32,ENCODING=PLAIN");
 
-      // seq chunk : [1,10]
       try {
         statement.execute("INSERT INTO root.sg1.d0(timestamp, s0, s1) VALUES (1, 1, 2.2)");
         fail();
@@ -200,6 +200,37 @@ public class IoTDBSimpleQueryIT {
     }
   }
 
+
+  @Test
+  public void testPartialInsertionAllFailed() throws SQLException, ClassNotFoundException {
+    Class.forName(Config.JDBC_DRIVER_NAME);
+
+    boolean autoCreateSchemaEnabled = IoTDBDescriptor.getInstance().getConfig()
+        .isAutoCreateSchemaEnabled();
+    boolean enablePartialInsert = IoTDBDescriptor.getInstance().getConfig().isEnablePartialInsert();
+
+    try(Connection connection = DriverManager
+        .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/",
+            "root", "root");
+        Statement statement = connection.createStatement()){
+      IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(false);
+      IoTDBDescriptor.getInstance().getConfig().setEnablePartialInsert(true);
+
+      statement.execute("SET STORAGE GROUP TO root.sg1");
+
+      try {
+        statement.execute("INSERT INTO root.sg1(timestamp, s0) VALUES (1, 1)");
+        fail();
+      } catch (IoTDBSQLException e) {
+        assertTrue(e.getMessage().contains("s0"));
+      }
+    }
+
+    IoTDBDescriptor.getInstance().getConfig().setEnablePartialInsert(enablePartialInsert);
+    IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(autoCreateSchemaEnabled);
+
+  }
+
   @Test
   public void testOverlappedPagesMerge() throws SQLException, ClassNotFoundException {
     Class.forName(Config.JDBC_DRIVER_NAME);