zhangshenghang opened a new pull request, #13707:
URL: https://github.com/apache/seatunnel/pull/13707
### Contribution acknowledgement
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 does
Adds `WaitStrategyQueuedJobHandoffIT`, an E2E regression guard for the
**handoff from a naturally finishing fixed-slot job to the jobs already queued
behind it under `job-schedule-strategy: WAIT`** in the Zeta engine.
The fixture is a single in-JVM Zeta node with four fixed slots
(`dynamic-slot: false`, `slot-num: 4`, `ScheduleStrategy.WAIT`):
- the **holder** is a batch job with parallelism 1 (one split enumerator +
one chained source-and-sink task, two slots) whose sink writer parks in
`close()` on the existing `FinalCheckpointCloseHoldGate` after all rows are
durable, so it keeps owning its slots;
- two **waiters** with parallelism 2 each need three slots. While the holder
owns two of the four slots, each waiter can obtain only the two remaining
slots, must release that partial grant, and must stay `PENDING` for several 3 s
pending-scheduler cycles;
- the gates are then released step by step, and the test requires that:
- the holder reaches `FINISHED`, the **first waiter alone** is admitted,
runs and parks both of its writers in `close()`;
- the **second waiter stays `PENDING`** and
`CoordinatorService#getPendingJobCount()` drops from 2 to 1 instead of both
waiters being admitted at once;
- after releasing the first waiter, the second one is admitted, the
pending count reaches 0, and all three jobs write exactly their expected rows
(`20`, `40`, `40`), proving the admitted jobs really executed and were not
duplicated or re-submitted.
The fixture uses only `FakeSource` and a test-tree sink; no Transform, SQL
semantics, connector or format behavior is exercised.
### Why this is a boundary with real regression risk
Under `WAIT`, `CoordinatorService#pendingJobSchedule` re-evaluates the queue
head every few seconds. `JobMaster#preApplyResources` grants whatever slots it
can obtain, then releases that partial grant when one task group cannot be
satisfied, and only then returns `false`. Capacity is reusable only if three
independent paths keep working together:
1. the terminal pipeline releases every fixed slot,
2. each waiter's partial pre-apply releases the slots it temporarily
obtained on **every** retry cycle,
3. the pending scheduler re-evaluates the queue head after the release and
admits exactly the head.
Leaking a single slot on any of those paths erodes capacity on every cycle,
so the waiters stay `PENDING` forever on an idle cluster while every job still
reports a valid state. Admitting two waiters at once double-books the same
slots. Neither failure is visible from a single job's status, so it cannot be
pinned by a unit test of a fabricated job master.
### Why existing coverage does not reach it
- `SeaTunnelSlotIT` covers a job rejected for lack of slots and a second job
submitted after a failed job released its slots.
- `PendingJobsRestIT` only reads the pending REST endpoint while one job
waits.
- `TagFilterLateWorkerPlacementIT` admits a waiter when a **new worker
joins**, which is a capacity-growth path, not the release path.
- `SplitClusterPendingJobLifecycleFailoverIT` drives the queue across master
ownership changes.
- No test in the tree lets queued jobs wait for a **naturally finishing**
holder and verifies that released slots admit exactly one waiter at a time, in
submission order, with complete output.
`SplitClusterFaultToleranceIT#testManyPipelinesRestoreContentionInWorkerDown`
is `@Disabled` for the separate #12202 scheduler-completion gap and does not
cover this path.
### Does this PR introduce _any_ user-facing change?
No. Test-only change: one E2E class, no new resources, no production or
configuration change.
### How was this patch tested?
```
./mvnw -o -pl
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base spotless:apply
./mvnw -o -pl
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
-DskipUT=true -DskipIT=false -Dit.test=WaitStrategyQueuedJobHandoffIT \
-DfailIfNoTests=false verify
```
Result: `Tests run: 1, Failures: 0, Errors: 0, Skipped: 0` (about 28 s on
JDK 17). The test was run repeatedly (surefire and failsafe) with the same
result.
The pending cycles in that run log show the partial grant being exercised,
e.g. `Pre resource application failed ... success: 2, failed: 1/3` and
`required: 1 slots, applied: 0 slots ... remaining: 1 slots not assigned`,
followed by the handoff.
Negative control: with the fixture's `SLOT_NUM` temporarily raised from 4 to
5, the holder leaves three free slots, the first waiter is admitted
immediately, and the test fails as intended:
```
Waiting for job 1179219919921807361 to reach PENDING ==> expected: <PENDING>
but was: <RUNNING>
```
after which the fixture value was restored and the test passes again.
--
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]