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

jackietien pushed a commit to branch AutoCleanBug-1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1a5f7c92a8aac7b013aa23e9693ba87ed59808a0
Author: JackieTien97 <[email protected]>
AuthorDate: Wed May 14 16:09:32 2025 +0800

    Fix auto cleaning partition table bug
---
 .../apache/iotdb/commons/partition/SeriesPartitionTable.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java
index f99d06c9c0d..069ecaf793d 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java
@@ -22,14 +22,15 @@ package org.apache.iotdb.commons.partition;
 import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
 import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
 import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
 import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils;
+import org.apache.iotdb.commons.utils.TimePartitionUtils;
 import org.apache.iotdb.confignode.rpc.thrift.TTimeSlotList;
 
 import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TProtocol;
 import org.apache.tsfile.utils.ReadWriteIOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -49,11 +50,14 @@ import java.util.stream.Collectors;
 
 public class SeriesPartitionTable {
 
-  private static final Logger LOGGER = 
LoggerFactory.getLogger(SeriesPartitionTable.class);
+  // should only be used in CN scope, in DN scope should directly use 
TimePartitionUtils.getTimePartitionInterval()
+  private static final  long TIME_PARTITION_INTERVAL = 
CommonDateTimeUtils.convertMilliTimeWithPrecision(
+      TimePartitionUtils.getTimePartitionInterval(), 
CommonDescriptor.getInstance().getConfig().getTimestampPrecision());
 
   private final ConcurrentSkipListMap<TTimePartitionSlot, 
List<TConsensusGroupId>>
       seriesPartitionMap;
 
+
   public SeriesPartitionTable() {
     this.seriesPartitionMap = new ConcurrentSkipListMap<>();
   }
@@ -255,7 +259,7 @@ public class SeriesPartitionTable {
     while (iterator.hasNext()) {
       Map.Entry<TTimePartitionSlot, List<TConsensusGroupId>> entry = 
iterator.next();
       TTimePartitionSlot timePartitionSlot = entry.getKey();
-      if (timePartitionSlot.getStartTime() + TTL < 
currentTimeSlot.getStartTime()) {
+      if (timePartitionSlot.getStartTime() + TIME_PARTITION_INTERVAL + TTL <= 
currentTimeSlot.getStartTime()) {
         removedTimePartitions.add(timePartitionSlot);
         iterator.remove();
       }

Reply via email to