Skip to content

Commit

Permalink
梳理 ExpireSnapshot 逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
askwang committed Jul 19, 2024
1 parent 1e9cd21 commit 5595881
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public void cleanUnusedIndexManifests(Snapshot snapshot, Set<String> skippingSet
public void cleanUnusedManifestList(String manifestName, Set<String> skippingSet) {
List<String> toDeleteManifests = new ArrayList<>();
List<ManifestFileMeta> toExpireManifests = tryReadManifestList(manifestName);
// 删除 manifest-file 文件
for (ManifestFileMeta manifest : toExpireManifests) {
String fileName = manifest.fileName();
if (!skippingSet.contains(fileName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Snapshot> skippingSnapshots =
TagManager.findOverlappedSnapshots(
taggedSnapshots, beginInclusiveId, endExclusiveId);
skippingSnapshots.add(snapshotManager.snapshot(endExclusiveId));
// 记录 baseManifestList、deltaManifestList、manifest 文件名
Set<String> 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);
Expand Down

0 comments on commit 5595881

Please sign in to comment.