From 5595881a090aa54fa6cfcab21946aac64da74017 Mon Sep 17 00:00:00 2001 From: Askwang <135721692+Askwang@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A2=B3=E7=90=86=20ExpireSnapshot=20=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/apache/paimon/operation/FileDeletionBase.java | 1 + .../java/org/apache/paimon/table/ExpireSnapshotsImpl.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/operation/FileDeletionBase.java b/paimon-core/src/main/java/org/apache/paimon/operation/FileDeletionBase.java index 37063f5fb9ac8..5fcd529ac5d8c 100644 --- a/paimon-core/src/main/java/org/apache/paimon/operation/FileDeletionBase.java +++ b/paimon-core/src/main/java/org/apache/paimon/operation/FileDeletionBase.java @@ -293,6 +293,7 @@ public void cleanUnusedIndexManifests(Snapshot snapshot, Set skippingSet public void cleanUnusedManifestList(String manifestName, Set skippingSet) { List toDeleteManifests = new ArrayList<>(); List toExpireManifests = tryReadManifestList(manifestName); + // 删除 manifest-file 文件 for (ManifestFileMeta manifest : toExpireManifests) { String fileName = manifest.fileName(); if (!skippingSet.contains(fileName)) { 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 74b8cf1995483..cee9c720fc120 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 @@ -219,14 +219,16 @@ public int expireUntil(long earliestId, long endExclusiveId) { snapshotDeletion.cleanDataDirectories(); } - // 过滤出不应该被删除的 snapshot manifest 和文件,因为 tag snapshot 会依赖 + // 过滤出不应该被删除的 snapshot manifest 和文件,因为 taggedSnapshot 会依赖 // delete manifests and indexFiles List skippingSnapshots = TagManager.findOverlappedSnapshots( taggedSnapshots, beginInclusiveId, endExclusiveId); skippingSnapshots.add(snapshotManager.snapshot(endExclusiveId)); + // 记录 baseManifestList、deltaManifestList、manifest 文件名 Set skippingSet = snapshotDeletion.manifestSkippingSet(skippingSnapshots); + // 删除过期 snapshot 的 manifest 文件、snapshot 目录文件 for (long id = beginInclusiveId; id < endExclusiveId; id++) { if (LOG.isDebugEnabled()) { LOG.debug("Ready to delete manifests in snapshot #" + id);