diff --git a/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java b/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java index dc1c2d6bdbc5..ab89cad26bf1 100644 --- a/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java +++ b/paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java @@ -115,6 +115,11 @@ public int expire() { // protected by 'snapshot.expire.limit' // (the maximum number of snapshots allowed to expire at a time) + long maxExclusiveByExpireLimit = earliest + maxDeletes; + while (!snapshotManager.snapshotExists(maxExclusiveByExpireLimit)) { + // Ensure maxExclusive exist, deal some snapshot between earliest and latest is deleted + maxExclusiveByExpireLimit++; + } maxExclusive = Math.min(maxExclusive, earliest + maxDeletes); for (long id = min; id < maxExclusive; id++) {