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

   Yes — I am contributing this change to Apache SeaTunnel, and I confirm it 
follows the project's
   contribution conventions (English PR title/description, one focused change, 
formatting and E2E
   validated locally). This is a test-only change: no production code, 
configuration default, REST/API
   or data format is modified.
   
   ## What this PR adds
   
   Adds `CancelWinsOverWorkerFailureIT`, an E2E regression guard for the 
cancellation contract fixed by
   #12377 for issue #12353 ("Worker crash during cancellation resolves job as 
FAILED"). The upstream fix
   shipped unit tests only (`StateTransitionCleanupTest`, `SubPlanTest`); this 
test pins the observable
   engine behaviour end to end.
   
   ## The contract
   
   The fixture runs on a separated cluster of **one master and three workers 
with one fixed slot each**,
   so the three task groups of the job (one FakeSource split-enumerator group 
plus the two chained
   source+sink groups of a two-parallelism pipeline) are forced onto three 
distinct workers. The sink
   writers park inside `write()` and swallow interrupts, so no chained task can 
acknowledge a
   cancellation:
   
   1. a graceful cancel is issued, the job reaches `CANCELING`, the pipeline 
reaches `CANCELING`, and
      both chained writers are provably still parked inside `write()` — the 
in-flight cancellation
      window is an observed fact, not a timing guess;
   2. the worker owning one of the two chained task groups is shut down, so the 
master books that vertex
      as `FAILED` through `CoordinatorService#failedTaskOnMemberRemoved` while 
the other chained writer
      is still parked and the cancellation is still in flight;
   3. for a whole stability window the pipeline must stay `CANCELING` and the 
job must stay `CANCELING`;
      neither may degrade to `FAILING`/`FAILED`;
   4. after the surviving writer is released, the job must resolve to 
`CANCELED` — through the live
      `JobMaster` completion future (with no failure error) and, once the 
coordinator has released the
      JobMaster, through finished-job history;
   5. the cancelled job must release every slot it still owned, so a capacity 
probe that needs both
      surviving fixed slots can start and then cancel cleanly.
   
   ## Why this is a boundary with real regression risk
   
   The pipeline end state is computed from task counters when the last vertex 
reports. A worker loss
   increments the failed counter while the cancellation is still being 
delivered, so a naive end-state
   computation turns the pipeline `FAILED` and the whole job `FAILED` even 
though the user cancelled it.
   That is #12353: the user-triggered cancellation is silently replaced by a 
failure, the job history
   records a failure that never happened, and the failed status is 
restore-eligible, which can keep a
   cancelled job trying to come back.
   
   #12377 fixed it by recording the cancel request before the cancel loop can 
block and giving the
   cancel precedence in the end-state computation. Nothing in the fix is 
visible from the job side until
   a worker is actually lost mid-cancel, which is exactly the condition no 
existing E2E creates.
   
   ## Why the existing coverage does not reach it
   
   - `ForceCancelUnresponsiveTaskIT` ends an unresponsive job through the 
force-stop path on a single
     node and never loses a worker.
   - `ClusterFaultToleranceIT`, `SplitClusterFaultToleranceIT` and the 
worker-restart ITs kill workers of
     jobs that are running normally and expect a restore; they never cancel 
first.
   - `CancelDuringDeployIT`, `CancelMasterFailoverIT` and 
`SplitClusterTerminalZombieJobMasterSwitchIT`
     race the cancel against master loss, deployment, or a terminal zombie job, 
not against the failure
     of a worker that hosts a still-running chained task.
   - `StateTransitionCleanupTest` (shipped with #12377) drives `SubPlan` state 
transitions directly and
     never runs a real task group on a real worker.
   
   No existing E2E asserts that a user cancellation survives a worker failure.
   
   ## Fixture and determinism
   
   - `CancelWinsOverWorkerFailureIT` — in-JVM split cluster (master + three 
lite workers), fixed slots
     (`dynamic-slot: false`, `slot-num: 1`), `ScheduleStrategy.WAIT`, 
checkpoint interval pushed far out
     (one hour) so no checkpoint barrier reaches the parked writers.
   - `CancelWorkerRaceHoldSink` / `CancelWorkerRaceHoldSinkFactory` — test-only 
sink registered through
     `@AutoService`, writers park in `write()` only after the test arms them 
and always swallow
     interrupts; `release()` is called from the test's `finally` block so a 
failed assertion cannot leave
     a parked task behind.
   - `cancel-worker-failure/stream_fake_to_cancel_worker_hold_sink.conf` — one 
STREAMING
     `FakeSource -> sink` pipeline at parallelism 2 (plain fixture, no 
Transform, SQL semantics,
     connector or format behaviour is exercised).
   - `cancel-worker-failure/stream_fake_to_console_capacity_probe.conf` — the 
two-slot capacity probe.
   
   Because every worker exposes exactly one fixed slot and the job needs 
exactly three slots, the two
   chained task groups are placed on two different workers by construction; the 
test asserts that
   placement before killing one of them, so the "one task failed, one task 
still parked" shape cannot be
   a lucky race.
   
   ## Evidence
   
   - Green with the pristine `engine-server` jar (sha256
     `e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`): five 
targeted runs before a
     Javadoc/format-only cleanup and three final runs after it, `24.677 s`, 
`24.982 s`, `24.908 s`,
     `24.777 s`, `24.808 s`, `25.129 s`, `24.803 s`.
   - Observed evidence in the logs: task group
     `TaskGroupLocation{jobId=..., pipelineId=1, taskGroupId=3}` on the killed 
worker ends with
     `state FAILED ... deployed node([localhost]:5804) offline` while the other 
chained writer is still
     parked, and the job then resolves to `CANCELED`.
   - Negative control: in `SubPlan`, remove the `cancelRequested` guard in the 
failed-vertex callback and
     the cancel-precedence branch of `determinePipelineEndState` (pre-#12377 
behaviour), rebuild and
     install `engine-server`. The test fails in `110.7 s` with
     `a worker failure must not overwrite the cancellation that was already in 
flight: the pipeline
     turned FAILING ==> expected: not equal but was: <FAILING>`. The mutation 
was reverted, the pristine
     `engine-server` jar was rebuilt and reinstalled (sha256 back to
     `e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`), and 
the green runs were
     repeated.
   - `spotless:check` (bound to `validate`) exit 0, `ImportClassCheckTest` 8/8, 
`git diff --check`
     clean.
   - Run command:
     `mvn -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base verify 
-DskipUT=true -DskipIT=false -Dit.test=CancelWinsOverWorkerFailureIT 
-DfailIfNoTests=false`
   
   ## Does this PR introduce any user-facing change?
   
   No. Test-only change: one E2E class, two test fixtures and two test 
resources; no production or
   configuration change.
   
   ## Scope
   
   No issue is filed because #12353 is already closed by #12377 and the 
contract holds on `dev`; the
   negative control shows the new test fails when the cancellation precedence 
is removed. The test
   references #12353 and #12377 as the regression it guards.
   


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