This is an automated email from the ASF dual-hosted git repository.
jiangtian 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 749d5f5e13c Fix delete NPE after insert failed (#17122)
749d5f5e13c is described below
commit 749d5f5e13ca8bc0eca23e26e64654d17f05e150
Author: Haonan <[email protected]>
AuthorDate: Fri Jan 30 18:06:13 2026 +0800
Fix delete NPE after insert failed (#17122)
---
.../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];