You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2026/02/28 01:48:15 UTC

(paimon) branch master updated: [core] Update lastFullCompaction in EarlyFullCompaction when triggering full compaction via size thresholds (#7314)

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

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new eb35e52aab [core] Update lastFullCompaction in EarlyFullCompaction when triggering full compaction via size thresholds (#7314)
eb35e52aab is described below

commit eb35e52aab8be1453cbb77f53b29dd662aa3604f
Author: lxy <38...@users.noreply.github.com>
AuthorDate: Sat Feb 28 09:48:09 2026 +0800

    [core] Update lastFullCompaction in EarlyFullCompaction when triggering full compaction via size thresholds (#7314)
---
 .../mergetree/compact/EarlyFullCompaction.java     |  2 +
 .../mergetree/compact/EarlyFullCompactionTest.java | 46 ++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/EarlyFullCompaction.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/EarlyFullCompaction.java
index 74fb003ed3..7b7185dd7b 100644
--- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/EarlyFullCompaction.java
+++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/EarlyFullCompaction.java
@@ -87,6 +87,7 @@ public class EarlyFullCompaction {
                 totalSize += run.run().totalSize();
             }
             if (totalSize < totalSizeThreshold) {
+                updateLastFullCompaction();
                 return Optional.of(CompactUnit.fromLevelRuns(maxLevel, runs));
             }
         }
@@ -98,6 +99,7 @@ public class EarlyFullCompaction {
                 }
             }
             if (incrementalSize > incrementalSizeThreshold) {
+                updateLastFullCompaction();
                 return Optional.of(CompactUnit.fromLevelRuns(maxLevel, runs));
             }
         }
diff --git a/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/EarlyFullCompactionTest.java b/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/EarlyFullCompactionTest.java
index 35665ed690..b4f1850527 100644
--- a/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/EarlyFullCompactionTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/EarlyFullCompactionTest.java
@@ -202,6 +202,52 @@ public class EarlyFullCompactionTest {
         assertThat(trigger.tryFullCompact(5, createRuns(300, 300))).isEmpty();
     }
 
+    @Test
+    public void testUpdateLastWhenFullCompactIsTriggeredByTotalSize() {
+        AtomicLong time = new AtomicLong(10_000);
+        TestableEarlyFullCompaction trigger =
+                new TestableEarlyFullCompaction(1000L, 500L, null, time);
+
+        // First time, interval should trigger even if size (600) > threshold (500)
+        Optional<CompactUnit> compactUnit = trigger.tryFullCompact(5, createRuns(300, 300));
+        assertThat(compactUnit).isPresent();
+        assertThat(compactUnit.get().outputLevel()).isEqualTo(4);
+
+        // Second time, compaction triggered by totalSizeThreshold
+        time.addAndGet(100); // now 10_100
+        compactUnit = trigger.tryFullCompact(5, createRuns(300, 100));
+        assertThat(compactUnit).isPresent();
+        assertThat(compactUnit.get().outputLevel()).isEqualTo(4);
+
+        // Third time, compaction cannot be triggered as 11001 - 10100 < 1000 fullCompactionInterval
+        time.addAndGet(901); // now 11_001
+        compactUnit = trigger.tryFullCompact(5, createRuns(300, 300));
+        assertThat(compactUnit).isEmpty();
+    }
+
+    @Test
+    public void testUpdateLastWhenFullCompactIsTriggeredByIncSize() {
+        AtomicLong time = new AtomicLong(10_000);
+        TestableEarlyFullCompaction trigger =
+                new TestableEarlyFullCompaction(1000L, null, 500L, time);
+
+        // First time, interval should trigger even if size (400) < threshold (500)
+        Optional<CompactUnit> compactUnit = trigger.tryFullCompact(5, createRuns(300, 100));
+        assertThat(compactUnit).isPresent();
+        assertThat(compactUnit.get().outputLevel()).isEqualTo(4);
+
+        // Second time, compaction triggered by totalSizeThreshold
+        time.addAndGet(100); // now 10_100
+        compactUnit = trigger.tryFullCompact(5, createRuns(300, 300));
+        assertThat(compactUnit).isPresent();
+        assertThat(compactUnit.get().outputLevel()).isEqualTo(4);
+
+        // Third time, compaction cannot be triggered as 11001 - 10100 < 1000 fullCompactionInterval
+        time.addAndGet(901); // now 11_001
+        compactUnit = trigger.tryFullCompact(5, createRuns(300, 100));
+        assertThat(compactUnit).isEmpty();
+    }
+
     private LevelSortedRun createLevelSortedRun(long size) {
         return createLevelSortedRun(0, size);
     }