zhangshenghang opened a new pull request, #13489:
URL: https://github.com/apache/seatunnel/pull/13489

   Thanks for contributing to Apache SeaTunnel! This PR only adds test coverage 
and a test fixture option; it does not change engine, connector or 
configuration behaviour.
   
   ## Background
   
   `CheckpointCoordinator#restoreTaskState(TaskLocation)` does not restore a 
task's state directly from the checkpoint. It walks the `(ActionStateKey, 
index)` tuples of the checkpoint plan and remaps the saved subtask states onto 
the *current* parallelism of each action:
   
   ```java
   for (int i = index; i < actionState.getParallelism(); i += 
currentParallelism) { ... }
   ```
   
   If that stride is derived from something that is always one per task (for 
example the `pipelineTasks` map, which is keyed by 
`TaskLocation#getTaskVertexId()` and therefore holds exactly one entry per 
subtask), subtask 0 absorbs the saved state of *every* subtask. With 
parallelism greater than one the duplicated state is handed back to a reader 
that already owns it, so the restored job re-reads and re-commits data the 
previous run had already committed. With parallelism one there is nothing to 
duplicate, which is why the existing restore tests cannot see the difference.
   
   That regression was fixed in #12195, but its only test 
(`CheckpointCoordinatorTest`) fabricates an already-built plan and 
already-saved subtask states and calls the remap indirectly. 
`SavepointRestoreIT`, `CheckpointRestoreWithStopIT` and 
`SavepointClusterRestartRestoreIT` all run the checkpointable sequence fixture 
with `parallelism = 1` and `split_num = 1`, so no end-to-end test ever restores 
two distinct per-subtask states onto two subtasks.
   
   ## What this PR adds
   
   - `ParallelSubtaskSavepointRestoreIT`: an in-process one-master/one-worker 
Zeta cluster running a two-subtask pipeline where each reader owns one split of 
a finite sequence. The job is stopped with a real savepoint mid-stream, 
restored once, and must then commit every offset in `[0, 4000)` **exactly 
once** and end `FINISHED`. A duplicated subtask state makes a restored reader 
replay an already committed range, so the duplicate-offset assertion fails 
instead of the job silently breaking exactly-once.
   - An opt-in `one_split_per_reader` option on the e2e 
`CheckpointableSequenceSource` fixture (default `false`). The default keeps the 
historical behaviour so existing container tests are unaffected; the new mode 
is required because the old behaviour drains every pending split into the first 
reader, leaving the other subtasks with an empty checkpoint state and nothing 
to remap. Restore hands a reader's splits back through `addSplitsBack` before 
that reader registers, so those returned splits are held per reader and handed 
back when it registers.
   - `stream_checkpointable_sequence_two_parallel_restore_template.conf`: the 
job template (2 readers, 2 splits, local file sink with per-checkpoint 
transactions).
   
   ## Verification
   
   - `./mvnw -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base -DskipUT 
-DskipIT=false -Dit.test=ParallelSubtaskSavepointRestoreIT verify` — passes, 1 
test, ~21s (JDK 17, in-process master + worker, no container needed).
   - `./mvnw spotless:apply` on both touched modules.
   - The job is observed to reach `SAVEPOINT_DONE` with offsets from both 
splits committed before the restore, and `FINISHED` with all 4000 offsets 
committed exactly once after it.
   
   Related: #12195 (regression this E2E guards). No new issue is filed because 
this is coverage for an already fixed defect; no production code is touched.


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