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

yuxia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluss.git


The following commit(s) were added to refs/heads/main by this push:
     new 57cb37887 [server] Fix PeriodicSnapshotManager.start() silently 
disables snapshot (#2978)
57cb37887 is described below

commit 57cb378872971c6b34c50aa86f9f69ef58bd7394
Author: Yang Wang <[email protected]>
AuthorDate: Thu Apr 2 10:33:50 2026 +0800

    [server] Fix PeriodicSnapshotManager.start() silently disables snapshot 
(#2978)
---
 .../server/kv/snapshot/PeriodicSnapshotManager.java      |  5 ++---
 .../server/kv/snapshot/PeriodicSnapshotManagerTest.java  | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git 
a/fluss-server/src/main/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManager.java
 
b/fluss-server/src/main/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManager.java
index 566d6ab10..c69e94634 100644
--- 
a/fluss-server/src/main/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManager.java
+++ 
b/fluss-server/src/main/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManager.java
@@ -165,14 +165,13 @@ public class PeriodicSnapshotManager implements Closeable 
{
     }
 
     public void start() {
-        // disable periodic snapshot when periodicMaterializeDelay is not 
positive
-        if (!started && initialDelay > 0) {
+        if (!started && snapshotIntervalSupplier.getAsLong() > 0) {
 
             started = true;
 
             LOG.info("TableBucket {} starts periodic snapshot", tableBucket);
 
-            scheduleNextSnapshot(initialDelay);
+            scheduleNextSnapshot(Math.max(initialDelay, 1));
         }
     }
 
diff --git 
a/fluss-server/src/test/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManagerTest.java
 
b/fluss-server/src/test/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManagerTest.java
index 018d980fb..4fb98ca1a 100644
--- 
a/fluss-server/src/test/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManagerTest.java
+++ 
b/fluss-server/src/test/java/org/apache/fluss/server/kv/snapshot/PeriodicSnapshotManagerTest.java
@@ -127,6 +127,22 @@ class PeriodicSnapshotManagerTest {
                 .hasMessage(exceptionMessage);
     }
 
+    @Test
+    void testStartWhenInitialDelayIsZero() {
+        // When periodicSnapshotDelay = 1, murmurHash(...) % 1 == 0 always,
+        // so initialDelay = 0. With a positive snapshot interval, start()
+        // should still schedule snapshots — but the current "initialDelay > 0"
+        // guard silently skips scheduling.
+        periodicSnapshotManager = createSnapshotManager(1L, 
NopSnapshotTarget.INSTANCE);
+        periodicSnapshotManager.start();
+
+        // A positive interval means snapshots should be scheduled.
+        // With the bug, this assertion fails: no task is scheduled.
+        assertThat(scheduledExecutorService.getAllScheduledTasks())
+                .as("snapshot should be scheduled even when initialDelay is 0")
+                .hasSize(1);
+    }
+
     @Test
     void testDynamicSnapshotInterval() {
         long initialInterval = 10_000L;

Reply via email to