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

jiangtian pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new c7f03dfa9b4 Fix delete NPE after insert failed (#17122) (#17125)
c7f03dfa9b4 is described below

commit c7f03dfa9b4c51b64af14f1539799a59d9efa576
Author: Haonan <[email protected]>
AuthorDate: Wed Feb 4 09:55:06 2026 +0800

    Fix delete NPE after insert failed (#17122) (#17125)
---
 .../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 dd97c18a049..7e5287f8a5a 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
@@ -395,6 +395,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 8ce2185d9ec..c9aff982c4b 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
@@ -1302,8 +1302,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[] costsForMetrics = new long[4];

Reply via email to