Skip to content
Open
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 @@ -315,6 +315,19 @@ public Long watermark() {

@Override
public void restore(@Nullable Long nextSnapshotId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar possible situations need to be taken into consideration, for example:

A previous asynchronous compaction may expire and delete the snapshot files that the source is about to read.

Possible sequence:
The source selects snapshot N for reading
-> a previous asynchronous compaction commits a newer snapshot
-> snapshot N or its manifest files are deleted
-> the source continues reading snapshot N
-> the read fails with OutOfRangeException or FileNotFoundException

This is a read-time race and can happen even without a Flink failover.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can treat it as a source-and-sink recovery problem, follows:
detect expired snapshot(include normal read or checkpoint restore)
-> discard expired pending splits
-> build a baseline from the latest valid snapshot
-> notify all compaction writers
-> rebuild writer state
-> ignore in-flight splits covered by the new baseline
-> continue from the next snapshot

if (nextSnapshotId != null) {
Long earliestSnapshotId = snapshotManager.earliestSnapshotId();
if (earliestSnapshotId != null && earliestSnapshotId > nextSnapshotId) {
LOG.warn(
"The restored snapshot with id {} has expired. "
+ "The earliest snapshot is {}. "
+ "Falling back to starting scanner.",
nextSnapshotId,
earliestSnapshotId);
this.nextSnapshotId = null;
return;
}
}
this.nextSnapshotId = nextSnapshotId;
}

Expand Down
Loading