You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2025/05/29 08:28:43 UTC
(iotdb) 11/14: Fix auto cleaning partition table bug
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.4
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 75aa36a2332e7ede5fdc8a03d3957315b420e042
Author: Jackie Tien <ja...@gmail.com>
AuthorDate: Wed May 14 19:41:46 2025 +0800
Fix auto cleaning partition table bug
(cherry picked from commit 145d87da438c90380b2ebb32fcf0591d800b50b4)
---
.../iotdb/commons/partition/SeriesPartitionTable.java | 15 +++++++++++----
1 file changed, 11 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..f46344566dc 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,7 +50,12 @@ 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;
@@ -255,7 +261,8 @@ 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();
}