diff --git a/fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java b/fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java index c8e26ea7b5..14a5a5f86e 100644 --- a/fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java +++ b/fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java @@ -690,10 +690,12 @@ void testRestore(@TempDir Path snapshotKvTabletDirPath) throws Exception { // We have to remove the first scheduled snapshot task since it's for the previous kv tablet // whose rocksdb has been dropped. + + // Remove the stale snapshot task if it exists scheduledExecutorService.removeNonPeriodicScheduledTask(); + // Trigger snapshot with retry to avoid flakiness + triggerSnapshotTaskWithRetry(scheduledExecutorService, 5); - // trigger one snapshot, - scheduledExecutorService.triggerNonPeriodicScheduledTask(); // wait until the snapshot success kvSnapshotStore.waitUntilSnapshotComplete(tableBucket, 0); @@ -717,7 +719,9 @@ void testRestore(@TempDir Path snapshotKvTabletDirPath) throws Exception { short newSchemaId = 2; // trigger one snapshot. scheduledExecutorService.removeNonPeriodicScheduledTask(); - scheduledExecutorService.triggerNonPeriodicScheduledTask(); + + triggerSnapshotTaskWithRetry(scheduledExecutorService, 5); + // wait until the snapshot success kvSnapshotStore.waitUntilSnapshotComplete(tableBucket, 1); // write data with old schema