Ivan-gfan opened a new pull request, #13422:
URL: https://github.com/apache/seatunnel/pull/13422
### Purpose of this pull request
Fixes #13421.
A transform can declare a smaller `parallelism` than its source. It is then
chained into the source task and runs in every source subtask, and each of
those subtasks acknowledges a checkpoint with its own index.
`CheckpointCoordinator#getActionStates` sized every `ActionState` by the
declared parallelism only, so the acknowledgement of subtask 1 failed in
`ActionState#reportState`:
```
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at
org.apache.seatunnel.engine.server.checkpoint.ActionState.reportState(ActionState.java:69)
at
org.apache.seatunnel.engine.server.checkpoint.PendingCheckpoint.acknowledgeTask(PendingCheckpoint.java:140)
at
org.apache.seatunnel.engine.server.checkpoint.CheckpointCoordinator.acknowledgeTask(CheckpointCoordinator.java:1340)
```
The coordinator already derives the number of subtasks running each action
(`actionParallelism`, from the subtask-to-action mapping) and uses it for the
restore remap. `getActionStates` now sizes each state by the larger of the
declared parallelism and that number.
### Does this PR introduce _any_ user-facing change?
Yes. A job whose transform declares a smaller parallelism than its source no
longer fails at the first checkpoint. Before, it failed with the exception
above, or, with `job.retry.times` > 0, was restarted and a batch job wrote its
rows more than once.
Checkpoint states of every other job keep their size: the change only
applies where more subtasks run an action than it declares, which is the case
that could not complete a checkpoint before. The restore remap already steps
through the slots by the running parallelism and skips empty ones.
### How was this patch tested?
-
`CheckpointCoordinatorTest#testActionStateHasSlotForEverySubtaskRunningTheAction`:
a transform declaring parallelism 1 that runs in two source subtasks gets two
slots and accepts the acknowledgement of subtask 1; an action declaring more
slots than running subtasks keeps its declared size.
- `TransformParallelismCheckpointIT` (in-process engine,
`batch_fake_to_console_transform_parallelism_template.conf`): FakeSource with
parallelism 2 feeding a Copy transform with parallelism 1, a 1 s checkpoint
interval and no retries. The job must finish, and `SourceReceivedCount` and
`SinkWriteCount` must both equal the generated row count.
- Without the change in `CheckpointCoordinator`, the unit test fails with
`expected: <2> but was: <1>` and the IT fails with the job in `FAILED` and the
exception above.
- With the change, the checkpoint tests of `seatunnel-engine-server`
(`Checkpoint*Test`, 34 tests including the restore remap cases) and
`TransformParallelismCheckpointIT` pass locally.
### Check list
* [x] If any new Jar binary package adding in your PR, please add License
Notice according
[New License
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
(no new dependency)
* [x] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs (not needed)
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR. (not needed)
* [ ] If you are contributing the connector code, please check that the
following files are updated: (not a connector change)
--
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]