sun-9545sunoj commented on PR #13374:
URL: https://github.com/apache/seatunnel/pull/13374#issuecomment-7044701261

   Thanks @DanielLeens for the thorough review. I agree with all three 
findings; they are addressed in 1d802d1de.
   
   **1. Recovery fails closed** (`DualFormatCheckpointReader`)
   - If completed checkpoints exist but none is readable, `getLatestCheckpoint` 
/ `getCheckpoints` now throw a `CheckpointStorageException` naming the job, the 
pipeline and each failed candidate, instead of returning `null`.
   - "No checkpoint at all" (including `chk-*` dirs without `_metadata`) still 
returns `null`.
   - An unreadable v1 blob no longer hides a readable v2 checkpoint; the next 
readable candidate across both formats is used.
   - Storages without `ChunkSupportStorage` keep the exact v1 behavior.
   - Tests: v2-only all-corrupt → throws; corrupt v1 + valid v2 → v2 (both 
methods); corrupt v1 and no v2 → throws; only incomplete v2 → `null`. The 
existing valid-older fallback tests are unchanged.
   
   **2. A committed file is never deleted or replaced** (`ChunkSupportStorage`, 
`AbstractChunkSupportStorage`, `HdfsStorage`, `LocalFileStorage`)
   - `_metadata` is now **create-once**. A second commit of the same checkpoint 
fails with "already committed" and does not touch the existing file, also when 
the write fails half-way.
     - HDFS: rename into place, after an explicit existence check. HDFS rename 
never overwrites, but Hadoop's local `FileSystem` does, so the check is not 
left to rename.
     - Local storage: an atomic hard link, which fails if the target exists.
   - Chunks of a committed checkpoint are immutable: `writeChunk` refuses once 
`_metadata` exists.
   - Chunks of an *uncommitted* checkpoint may still be rewritten (an id 
attempted again after a restore). No `_metadata` references them yet, so a 
short window without the file is harmless.
   - Temporary files are now per attempt (`*.<uuid>.tmp`) and removed on 
failure.
   - The contract is in the SPI javadoc. I kept HDFS rename and object-store 
copy guarantees separate: object stores still rely on the `_metadata` CRC to 
detect a partial copy.
   - Tests (local file storage and the Hadoop storage on the local FS): a 
second commit fails, the original stays readable, a late chunk write to a 
committed checkpoint is refused, and no tmp files remain. The previous 
delete-then-rename code fails this test, because the second commit succeeded 
silently.
   
   **3. External handles through the real restore operation** 
(`CheckpointCoordinatorTest#testExternalStateIsResolvedThroughTheRealRestoreOperation`)
   - Steps:
     1. Writes real v2 chunks (enumerator plus two reader subtasks, with a null 
segment) and `_metadata` next to an older v1 checkpoint.
     2. Selects the checkpoint with `DualFormatCheckpointReader`.
     3. Deserializes it in a real `CheckpointCoordinator` and remaps it from 
parallelism 2 to 1 via `restoreTaskState`.
     4. Sends each `NotifyTaskRestoreOperation` through Hazelcast serialization 
and runs the real `runInternal`. Only the task and the executor lookup are 
stubbed.
   - Asserts the inline states that reach `Task#restoreState`.
   - Deleting one chunk makes the restore report 
`CheckpointErrorReportOperation` to the master, and the task never restores.
   - Mutation check: passing the unresolved states to the task makes the test 
fail.
   
   Docs: the developer-facing SPI, layout and invariants are in the 
`ChunkSupportStorage` / `CheckpointFileLayout` javadoc and in the PR 
description. User-facing docs will come with phase 3, together with the 
options, and I don't claim any master-memory savings for this PR. A baseline 
measurement is on #13360.
   
   Validation: `org.apache.seatunnel.engine.server.checkpoint` passes (71 run, 
0 failures, 2 existing skips), as do the storage module tests and `-DskipTests 
verify` on the changed modules. The checkpoint E2Es were run on the first 
commit and have not been re-run yet after these fixes.
   


-- 
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]

Reply via email to