Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy committed Jan 20, 2025
1 parent dbd129d commit a27e004
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public int expireUntil(long earliestId, long endExclusiveId) {
if (expireConfig.isChangelogDecoupled()) {
commitChangelog(new Changelog(snapshot));
}
snapshotManager.fileIO().deleteQuietly(snapshotManager.snapshotPath(id));
snapshotManager.deleteSnapshot(id);
}

writeEarliestHint(endExclusiveId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private List<Snapshot> cleanSnapshotsDataFiles(Snapshot retainedSnapshot) {
// Ignore the non-existent snapshots
if (snapshotManager.snapshotExists(i)) {
toBeCleaned.add(snapshotManager.snapshot(i));
fileIO.deleteQuietly(snapshotManager.snapshotPath(i));
snapshotManager.deleteSnapshot(i);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ public boolean snapshotExists(long snapshotId) {
}
}

public void deleteSnapshot(long snapshotId) {
Path path = snapshotPath(snapshotId);
if (cache != null) {
cache.invalidate(path);
}
fileIO().deleteQuietly(path);
}

public boolean longLivedChangelogExists(long snapshotId) {
Path path = longLivedChangelogPath(snapshotId);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ private void commitSnapshotHintInTargetTable(SnapshotManager targetTableSnapshot
targetTableSnapshotManager.commitLatestHint(snapshotId);
for (Snapshot snapshot : targetTableSnapshotManager.safelyGetAllSnapshots()) {
if (snapshot.id() != snapshotId) {
targetTableSnapshotManager
.fileIO()
.deleteQuietly(targetTableSnapshotManager.snapshotPath(snapshot.id()));
targetTableSnapshotManager.deleteSnapshot(snapshot.id());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,12 @@ class RollbackProcedureTest extends PaimonSparkTestBase with StreamTest {
}
}

test("Paimon Procedure: rollback with cache") {
sql("CREATE TABLE T (id INT)")
sql("INSERT INTO T VALUES (1), (2), (3), (4)")
sql("DELETE FROM T WHERE id = 1")
sql("CALL sys.rollback(table => 'T', version => '1')")
sql("DELETE FROM T WHERE id = 1")
checkAnswer(sql("SELECT * FROM T ORDER BY id"), Seq(Row(2), Row(3), Row(4)))
}
}

0 comments on commit a27e004

Please sign in to comment.