goutamadwant commented on code in PR #13717:
URL: https://github.com/apache/seatunnel/pull/13717#discussion_r4731269168
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointManager.java:
##########
@@ -225,14 +225,59 @@ private PipelineState getLatestCheckpointStateByType(
}
List<PipelineState> pipelineStates =
checkpointStorage.getCheckpointsByJobIdAndPipelineId(sourceJobId, pipelineId);
Review Comment:
A truncated checkpoint file still aborts the restore: `LocalFileStorage`
fails while decoding the envelope, before this loop runs. With 1 and 2 healthy
and the file of 3 cut in half, both selectors throw instead of picking 2.
Should the storage read skip such files as well?
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:
##########
@@ -112,29 +115,87 @@ public List<JobPipelineCheckpointData>
getLatestCheckpointData(
@SneakyThrows
public List<CompletedCheckpoint> getLatestCheckpointsForRestore(
String jobId, RestoreMode restoreMode) {
- return checkpointStorage.getAllCheckpoints(jobId).stream()
- .map(this::deserializeCheckpoint)
- .filter(
- checkpoint ->
-
CheckpointRestoreUtils.matchesRestoreCheckpointType(
- checkpoint.getCheckpointType(),
restoreMode))
-
.collect(Collectors.groupingBy(CompletedCheckpoint::getPipelineId))
- .values()
- .stream()
- .map(
- checkpoints ->
- checkpoints.stream()
- .max(
- Comparator.comparingLong(
-
CompletedCheckpoint
-
::getCheckpointId)
- .thenComparingLong(
-
CompletedCheckpoint
-
::getCompletedTimestamp)))
- .filter(Optional::isPresent)
- .map(Optional::get)
-
.sorted(Comparator.comparingInt(CompletedCheckpoint::getPipelineId))
- .collect(Collectors.toList());
+ List<PipelineState> pipelineStates =
checkpointStorage.getAllCheckpoints(jobId);
+ Map<Integer, List<CompletedCheckpoint>> healthyCheckpointsByPipeline =
new HashMap<>();
+ Map<Integer, Long> latestCorruptedCheckpointByPipeline = new
HashMap<>();
+ for (PipelineState pipelineState : pipelineStates) {
+ CompletedCheckpoint checkpoint;
+ try {
+ checkpoint = deserializeCheckpoint(pipelineState);
+ } catch (Exception e) {
+ // A checkpoint that cannot be deserialized (a truncated or
partially published
+ // write, a damaged disk block) must not abort the restore
while older healthy
+ // checkpoints still exist. Skipping it replays the data
produced after the
+ // selected older checkpoint; the WARN below tells the
operator why.
+ latestCorruptedCheckpointByPipeline.merge(
Review Comment:
Optional: a 0-byte checkpoint file decodes to pipeline 0 / checkpoint 0, so
this fails with "no healthy checkpoint is available for pipeline(s) [0]"
although pipeline 1 has healthy ones, while `CheckpointManager` falls back.
Maybe skip candidates with empty `states`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]