Skip to content

Commit 55d0395

Browse files
author
jiangqiao.xu
committed
[flink] Bugfix expire snapshot don't work when some snapshot between earliest and latest are removed for some reason
1 parent 8ade15f commit 55d0395

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

paimon-core/src/main/java/org/apache/paimon/table/ExpireSnapshotsImpl.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ public int expire() {
115115

116116
// protected by 'snapshot.expire.limit'
117117
// (the maximum number of snapshots allowed to expire at a time)
118-
maxExclusive = Math.min(maxExclusive, earliest + maxDeletes);
118+
long maxExclusiveByExpireLimit = earliest + maxDeletes;
119+
while (!snapshotManager.snapshotExists(maxExclusiveByExpireLimit)) {
120+
// Ensure maxExclusive exist, deal some snapshot between earliest and latest is deleted
121+
maxExclusiveByExpireLimit++;
122+
}
123+
maxExclusive = Math.min(maxExclusive, maxExclusiveByExpireLimit);
119124

120125
for (long id = min; id < maxExclusive; id++) {
121126
// Early exit the loop for 'snapshot.time-retained'

0 commit comments

Comments
 (0)