DanielLeens commented on code in PR #13717:
URL: https://github.com/apache/seatunnel/pull/13717#discussion_r4731342232
##########
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:
Thanks — that distinction is useful. The service enumerates all envelopes
and records corruption by their decoded pipeline ID, whereas the manager starts
with a requested pipeline's filename-filtered list. A zero-byte envelope that
becomes default pipeline/checkpoint 0 can consequently pollute the service's
all-corrupt-pipeline guard even when pipeline 1 has healthy data; a successful
manager fallback does not prove the service path is safe.
Validate the storage envelope/payload and expected identity before using
that default identity to create a pipeline requirement. An absent/zero-length
serialized payload is different from a legitimate decoded checkpoint whose
operators happen to have empty state, so a broad empty-operator-state filter
would be too strong. Keep healthy fallback and fail-closed behavior for a
genuinely known pipeline with no eligible checkpoint, and cover this zero-byte
case alongside truncation. This is a focused reply on the envelope-validation
boundary, not a claim that the current patch already handles it or that I ran
it locally.
--
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]