Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)))
}
}
Loading