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 2026/01/30 08:33:52 UTC

(iotdb) branch fix_delete_npe created (now 40391af05bc)

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

haonan pushed a change to branch fix_delete_npe
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 40391af05bc Fix delete NPE after insert failed

This branch includes the following new commits:

     new 40391af05bc Fix delete NPE after insert failed

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.



(iotdb) 01/01: Fix delete NPE after insert failed

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

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

commit 40391af05bcabaf93d5122701a47a2357b7f5cb7
Author: HTHou <ha...@apache.org>
AuthorDate: Fri Jan 30 16:33:35 2026 +0800

    Fix delete NPE after insert failed
---
 .../org/apache/iotdb/db/it/IoTDBDeletionIT.java    | 25 ++++++++++++++++++++++
 .../db/storageengine/dataregion/DataRegion.java    |  5 ++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
index 17ceb9b6962..8f8ec7daa64 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
@@ -400,6 +400,31 @@ public class IoTDBDeletionIT {
     }
   }
 
+  @Test
+  public void testDeleteDataAfterInsertFailed() throws SQLException {
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement()) {
+      statement.execute("create timeseries root.dd.wf01.wt01.status with datatype=BOOLEAN;");
+      statement.execute(
+          "INSERT INTO root.dd.wf01.wt01(Time,status) VALUES (2022-10-11 10:20:50,'rr');");
+    } catch (SQLException e) {
+      assertEquals(507, e.getErrorCode());
+    }
+
+    try (Connection connection = EnvFactory.getEnv().getConnection();
+        Statement statement = connection.createStatement()) {
+      statement.execute("DELETE FROM root.dd.wf01.wt01.status");
+
+      try (ResultSet resultSet = statement.executeQuery("select ** from root.dd")) {
+        int cnt = 0;
+        while (resultSet.next()) {
+          cnt++;
+        }
+        Assert.assertEquals(0, cnt);
+      }
+    }
+  }
+
   @Test
   public void testDelSeriesWithSpecialSymbol() throws SQLException {
     try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
index 0061f41f995..d95d51e390e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
@@ -1643,8 +1643,11 @@ public class DataRegion implements IDataRegionForQuery {
   private TsFileProcessor insertToTsFileProcessor(
       InsertRowNode insertRowNode, boolean sequence, long timePartitionId)
       throws WriteProcessException {
+    if (insertRowNode.allMeasurementFailed()) {
+      return null;
+    }
     TsFileProcessor tsFileProcessor = getOrCreateTsFileProcessor(timePartitionId, sequence);
-    if (tsFileProcessor == null || insertRowNode.allMeasurementFailed()) {
+    if (tsFileProcessor == null) {
       return null;
     }
     long[] infoForMetrics = new long[5];