Skip to content

Commit 05ff059

Browse files
authored
[Improvement] Move snapshot ID capture in expireFiles() to after delete commit (#4169)
Move snapshot ID capture in expireFiles() to after delete commit The snapshot ID passed to RewriteFiles.validateFromSnapshot() was captured before DeleteFiles.commit(), making it stale for the subsequent RewriteFiles operation. Although the current validation path is benign (replacedDataFiles is empty so conflict detection is skipped), passing a pre-commit snapshot ID is semantically incorrect and fragile against future Iceberg validation changes. Move the capture to after delete.commit() so that validateFromSnapshot() always receives the up-to-date snapshot. Signed-off-by: Jiwon Park <jpark92@outlook.kr>
1 parent 5abacab commit 05ff059

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

amoro-format-iceberg/src/main/java/org/apache/amoro/formats/iceberg/maintainer/IcebergTableMaintainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ public static Expression getDataExpression(
875875
}
876876

877877
public void expireFiles(ExpireFiles expiredFiles, long expireTimestamp) {
878-
long snapshotId = IcebergTableUtil.getSnapshotId(table, false);
879878
Queue<DataFile> dataFiles = expiredFiles.dataFiles;
880879
Queue<DeleteFile> deleteFiles = expiredFiles.deleteFiles;
881880
if (dataFiles.isEmpty() && deleteFiles.isEmpty()) {
@@ -890,6 +889,7 @@ public void expireFiles(ExpireFiles expiredFiles, long expireTimestamp) {
890889
delete.commit();
891890
// expire delete files
892891
if (!deleteFiles.isEmpty()) {
892+
long snapshotId = IcebergTableUtil.getSnapshotId(table, false);
893893
RewriteFiles rewriteFiles = table.newRewrite().validateFromSnapshot(snapshotId);
894894
deleteFiles.forEach(rewriteFiles::deleteFile);
895895
rewriteFiles.set(

0 commit comments

Comments
 (0)