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

haonan 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 b4e0b0278f5 Fix broken file genaterated after insert null to aligned 
timeseries (#15163)
b4e0b0278f5 is described below

commit b4e0b0278f542fc7c0535ecc4c58273e1bf1c989
Author: Haonan <[email protected]>
AuthorDate: Sat Mar 22 00:22:59 2025 +0800

    Fix broken file genaterated after insert null to aligned timeseries (#15163)
---
 .../iotdb/session/it/IoTDBSessionInsertNullIT.java | 28 ++++++++++++++++++++++
 .../dataregion/memtable/AbstractMemTable.java      |  5 ++--
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
index 4eb14e35c93..5fdf733578f 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.session.it;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionDataSet;
 import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
 import org.apache.iotdb.it.framework.IoTDBTestRunner;
 import org.apache.iotdb.itbase.category.ClusterIT;
 import org.apache.iotdb.itbase.category.LocalStandaloneIT;
@@ -43,11 +44,13 @@ import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
 @RunWith(IoTDBTestRunner.class)
@@ -421,6 +424,31 @@ public class IoTDBSessionInsertNullIT {
       session.executeNonQueryStatement("flush");
       nums = queryCountRecords(session, "select count(s1) from " + deviceId);
       assertEquals(0, nums);
+      for (DataNodeWrapper dn : EnvFactory.getEnv().getDataNodeWrapperList()) {
+        File dir =
+            new File(
+                dn.getDataDir()
+                    + File.separator
+                    + "datanode"
+                    + File.separator
+                    + "data"
+                    + File.separator
+                    + "sequence"
+                    + File.separator
+                    + "root.sg1"
+                    + File.separator
+                    + "1"
+                    + File.separator
+                    + "0");
+        if (dir.exists() && dir.isDirectory()) {
+          File[] files = dir.listFiles();
+          if (files != null) {
+            for (File file : files) {
+              assertFalse(file.getName().endsWith("broken"));
+            }
+          }
+        }
+      }
     } catch (Exception e) {
       e.printStackTrace();
       fail(e.getMessage());
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java
index 559d06da63c..d550781858f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/AbstractMemTable.java
@@ -952,9 +952,8 @@ public abstract class AbstractMemTable implements IMemTable 
{
   public Map<IDeviceID, Long> getMaxTime() {
     Map<IDeviceID, Long> latestTimeForEachDevice = new HashMap<>();
     for (Entry<IDeviceID, IWritableMemChunkGroup> entry : 
memTableMap.entrySet()) {
-      long maxTime = entry.getValue().getMaxTime();
-      if (entry.getValue().count() > 0) {
-        latestTimeForEachDevice.put(entry.getKey(), maxTime);
+      if (entry.getValue().count() > 0 && !entry.getValue().isEmpty()) {
+        latestTimeForEachDevice.put(entry.getKey(), 
entry.getValue().getMaxTime());
       }
     }
     return latestTimeForEachDevice;

Reply via email to