sun-9545sunoj commented on PR #13374: URL: https://github.com/apache/seatunnel/pull/13374#issuecomment-7060960892
@SEZ9 thanks for the thorough review. All eight issues are addressed in 2b9b1c019. **Issue 1 (read failure vs corrupt content).** There is a new `CorruptCheckpointException extends CheckpointStorageException`. It is thrown for invalid content: framing, length, CRC, deserialization, or a checkpoint id/identity mismatch. An I/O failure is reported as a plain `CheckpointStorageException`. `DualFormatCheckpointReader` now skips only corrupt candidates. A candidate that cannot be read fails the restore, even when an older readable checkpoint exists. On the Hadoop local FS, a `ChecksumException` from the `.crc` sidecar is an `IOException`, so it is a read failure as well. `testV1FileThatCannotBeReadFailsTheRestore` and `testV2MetadataThatCannotBeReadFailsTheRestore` cover both backends, and the latest, list and typed paths. They also assert that the failure is not reported as corruption. Making the reader skip read failures again fails these tests. **Issue 2 (chunk location).** `readChunk` now validates the location before opening anything: exactly `<job>/<pipeline>/chk-<id>/subtask-…-<attempt>.chunk`, with validated segments. Anything else, such as traversal, `_metadata` or `.tmp`, is rejected as corrupt. When `CheckpointCoordinator` deserializes a restored checkpoint, `checkExternalStateLocations` also requires every external handle to lie in the directory of that checkpoint's own job, pipeline and id. Tests: `CheckpointStateFormatTest#testChunkLocationValidation`, `LocalFileStorageTest#testChunkLocationOutsideTheLayoutIsNeverRead`, and `CheckpointSerializeTest#testRestoredExternalStateOutsideItsCheckpointIsRejected`. **Issue 3 (chunk binding).** Each chunk write gets a unique per-attempt file name and is published create-once, so a late or retried write can never replace a chunk that committed metadata references. The non-atomic "already committed" pre-check is gone. `FileChunkStateHandle` now carries `encodedLength` and `checksum` (CRC32) in addition to `stateSize`, and `readChunk` verifies all three. A replaced chunk with valid framing and the same length is rejected by its CRC (`testChunkContentIsBoundToItsHandle`, both plugins). **Issue 4 (v2 identity).** The `_metadata` payload is deserialized and must be the `CompletedCheckpoint` of the job, pipeline and `chk-<id>` it is stored under. Otherwise it is treated as corrupt. `testV2MetadataOfAnotherCheckpointIsSkipped` copies valid files from another checkpoint id, another pipeline and another job. **Issue 5 (id after fallback).** After a restore, `CheckpointManager` sets the counter to `max(restoredId, highestCommittedCheckpointId) + 1`. The highest committed id covers both formats, readable or not. `testNextCheckpointIdStartsAboveCorruptCommittedIds` shows that `restoredId + 1` is refused and that the chosen id commits. **Issue 6 (cleanup in finally).** Cleanup now runs only on the failure path, and a cleanup failure is added as suppressed to the original exception. A successful commit is never turned into a failure, and "already committed" keeps its `FileAlreadyExistsException` cause (`testTemporaryFileCleanupFailureDoesNotHideThePublicationOutcome`). HDFS no longer deletes a target before renaming: the new `moveIfAbsent` refuses an existing target on both plugins. **Issue 7 (typed restore).** The typed path now goes through `DualFormatCheckpointReader.getLatestCheckpointOfType`. The type of a corrupt candidate is unknown, so the restore fails if nothing matches and a candidate was corrupt. For `RestoreMode.SAVEPOINT` it also fails if a corrupt candidate is newer than the matching savepoint. A checkpoint restore falls back as on the latest path (`testTypedRestoreWithCorruptCandidatesFailsClosed`). **Issue 8 (docs).** I added a "Restoring from an unreadable checkpoint" section to `checkpoint-storage.md` and an entry to `incompatible-changes.md`, both in en and zh. The PR description's user-facing section now states the behavior change. Validation (JDK 11): - Storage modules: 10, 23 and 11 tests pass. - `org.apache.seatunnel.engine.server.checkpoint`: 95 run, 0 failures, 2 skipped (the existing `@Disabled` tests). - `spotless:check` and `-DskipTests verify` pass on the four modules. The E2E suites have not been re-run since the first commit. -- 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]
