Skip to content

Commit aa4b551

Browse files
authored
Fix Integer overflow when converting 604800000000000ms to -3942554432415203328ns (#17511)
1 parent 2304ae7 commit aa4b551

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@
5151
import java.util.stream.Collectors;
5252

5353
public class SeriesPartitionTable {
54-
55-
// should only be used in CN scope, in DN scope should directly use
56-
// TimePartitionUtils.getTimePartitionInterval()
57-
private static final long TIME_PARTITION_INTERVAL =
58-
CommonDateTimeUtils.convertMilliTimeWithPrecision(
59-
TimePartitionUtils.getTimePartitionInterval(),
60-
CommonDescriptor.getInstance().getConfig().getTimestampPrecision());
61-
6254
private final ConcurrentSkipListMap<TTimePartitionSlot, List<TConsensusGroupId>>
6355
seriesPartitionMap;
6456

@@ -263,13 +255,17 @@ public TConsensusGroupId getLastConsensusGroupId() {
263255
*/
264256
public List<TTimePartitionSlot> autoCleanPartitionTable(
265257
long TTL, TTimePartitionSlot currentTimeSlot) {
258+
final long timePartitionInterval =
259+
CommonDateTimeUtils.convertMilliTimeWithPrecision(
260+
TimePartitionUtils.getTimePartitionInterval(),
261+
CommonDescriptor.getInstance().getConfig().getTimestampPrecision());
266262
List<TTimePartitionSlot> removedTimePartitions = new ArrayList<>();
267263
Iterator<Map.Entry<TTimePartitionSlot, List<TConsensusGroupId>>> iterator =
268264
seriesPartitionMap.entrySet().iterator();
269265
while (iterator.hasNext()) {
270266
Map.Entry<TTimePartitionSlot, List<TConsensusGroupId>> entry = iterator.next();
271267
TTimePartitionSlot timePartitionSlot = entry.getKey();
272-
if (timePartitionSlot.getStartTime() + TIME_PARTITION_INTERVAL + TTL
268+
if (timePartitionSlot.getStartTime() + timePartitionInterval + TTL
273269
<= currentTimeSlot.getStartTime()) {
274270
removedTimePartitions.add(timePartitionSlot);
275271
iterator.remove();

0 commit comments

Comments
 (0)