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

jt2594838 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 410ab85f2ae Fix corrupted TsFile IT file selection (#18346)
410ab85f2ae is described below

commit 410ab85f2ae1e954035c0e39c837a3ea6160240a
Author: Caideyipi <[email protected]>
AuthorDate: Wed Jul 29 16:37:04 2026 +0800

    Fix corrupted TsFile IT file selection (#18346)
    
    Limit the corrupted file lookup to the test database and consume the full 
query result so corruption detected during later fetches is surfaced.
---
 .../recent/IoTDBQueryWithCorruptedTsFileIT.java     | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBQueryWithCorruptedTsFileIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBQueryWithCorruptedTsFileIT.java
index 58d2d2970dc..8a56ff4730c 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBQueryWithCorruptedTsFileIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBQueryWithCorruptedTsFileIT.java
@@ -44,6 +44,7 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.sql.Connection;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
@@ -175,17 +176,19 @@ public class IoTDBQueryWithCorruptedTsFileIT {
       statement.execute("FLUSH");
     }
 
-    // 2. Find the generated TsFile in the data directory
-    File sequenceDir =
+    // 2. Find a generated TsFile in this database's data directory
+    File databaseSequenceDir =
         new File(
             EnvFactory.getEnv().getDataNodeWrapper(0).getDataNodeDir()
                 + File.separator
                 + "data"
                 + File.separator
-                + "sequence");
-    File tsFile = findTsFileRecursively(sequenceDir);
+                + "sequence"
+                + File.separator
+                + DATABASE_NAME);
+    File tsFile = findTsFileRecursively(databaseSequenceDir);
     if (tsFile == null) {
-      fail("Could not find TsFile in data directory: " + 
sequenceDir.getAbsolutePath());
+      fail("Could not find TsFile in data directory: " + 
databaseSequenceDir.getAbsolutePath());
     }
 
     // 3. Corrupt the data section of the TsFile
@@ -196,7 +199,13 @@ public class IoTDBQueryWithCorruptedTsFileIT {
         Statement statement = connection.createStatement()) {
       statement.execute("USE " + DATABASE_NAME);
       try {
-        statement.execute("SELECT * FROM " + tableName + " ORDER BY time");
+        try (ResultSet resultSet =
+            statement.executeQuery("SELECT * FROM " + tableName + " ORDER BY 
time")) {
+          while (resultSet.next()) {
+            // Consume all rows because corruption may be detected while 
fetching later result
+            // blocks.
+          }
+        }
         fail("Expected query on corrupted TsFile to fail");
       } catch (SQLException e) {
         assertTrue(

Reply via email to