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

   Yes, I am contributing to Apache SeaTunnel. This change only adds regression 
coverage to the Zeta engine E2E suite; no production code is modified.
   
   ### What this PR does
   
   Adds 
`SeaTunnelSlotIT#testCanceledQueuedJobIsNeverDispatchedAfterCapacityIsReleased`,
 an end-to-end test for cancelling a job that is only *queued*, not running, 
under `ScheduleStrategy.WAIT`.
   
   The test runs a real single-JVM master/worker cluster with 
`dynamic-slot=false`, `slot-num=3` and `schedule-strategy=WAIT`. Both the 
holder and the victim use a new minimal streaming fixture 
(`cancel_queued_job_stream.conf`: one split enumerator plus one chain task 
group per parallelism index, three slots in total, `checkpoint.interval=5000`).
   
   Contract under test:
   
   1. The holder owns all three fixed slots and is really reading rows.
   2. The victim cannot fit and stays `PENDING`, not `FAILED`.
   3. Cancelling the victim reaches `CANCELED` and the victim stays `CANCELED` 
for a full observation window while the cluster is still full.
   4. The holder is cancelled, releasing the slots the victim was waiting for. 
For longer than a complete 3s scheduler retry cycle the victim must still be 
`CANCELED` and must never read a single row — the scheduler must not turn the 
cancelled queue entry into a dispatched job.
   5. A fresh job submitted afterwards still reaches `RUNNING` and reads rows, 
proving the cancellation neither broke the pending queue nor leaked a slot.
   
   ### Why this boundary has real regression risk
   
   `CoordinatorService#pendingJobSchedule` is a single long-lived thread that 
peeks the queue head, evaluates the job's slots through 
`JobMaster#preApplyResources`, and only then moves the job into 
`runningJobMasterMap` and calls `run()`. Cancelling a queued job runs on a 
different thread: it removes the entry from `pendingJobQueue` and flips the 
`JobMaster` to `CANCELED`. If the scheduler already reserved that entry 
(`schedulingPendingJobIds`) or a later iteration re-reads stale queue state, 
the cancelled job can still be dispatched once capacity appears. 
`PhysicalPlan#startJob` then tries to leave the terminal `CANCELED` state, the 
job is forced through `FAILING`, and it surfaces as `FAILED` — a job the user 
already cancelled. The window is invisible to the client that saw `CANCELED`, 
and in a full fixed-slot cluster the capacity that opens it may only arrive 
minutes later.
   
   ### Why existing coverage does not reach it
   
   - `CoordinatorServiceWithCancelPendingJobTest#testCancelPendingJob` cancels 
a hand-injected pending `JobMaster` and checks queue/IMap bookkeeping at that 
instant. No pending scheduler runs against real resources there, so nothing can 
be dispatched *after* the cancel and the release-then-dispatch path is never 
exercised.
   - `SplitClusterPendingJobLifecycleFailoverIT` covers dispatch of a *live* 
queued job and cancels only jobs that are already running; its head-of-line 
test keeps its queued job alive.
   - `SeaTunnelSlotIT#testSlotNotEnough` / 
`#testSlotReleasedAfterNotEnoughResourceFailure` use the default `FAIL` 
strategy, where an oversize request never enters the queue, and 
`PendingJobsRestIT` only inspects the REST view of one queued job.
   - The unit test above is also the only coverage that mentions a cancelled 
pending job at all, and it does not observe the queue after capacity is 
released.
   
   ### Verification
   
   ```
   mvn -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
verify \
     -DskipUT=true -DskipIT=false \
     -Dit.test='SeaTunnelSlotIT' -DfailIfNoTests=false
   ```
   
   - New test alone on this branch: passes, ~21s.
   - Full `SeaTunnelSlotIT` class on this branch: `Tests run: 4, Failures: 0, 
Errors: 0, Skipped: 0` (~32s), so the new test does not interfere with the 
existing slot exhaustion, slot-release and minimal-slot cases.
   - `spotless:apply` produces no changes.
   - The test is placed in `SeaTunnelSlotIT` rather than a new class because 
the scenario only becomes reachable through fixed-slot exhaustion, which is 
what this class already owns.
   - Searched open and closed issues/PRs for an equivalent scenario ("cancel 
pending job", "queued job canceled", "WAIT schedule pending", "canceled job 
dispatched"); none found. Related but distinct work: #10430 (pending queue 
rescheduling for WAIT), #13344 (pre-applied slot leak when a pending job is 
cancelled), #13483 (checkpoint-ID counter cleanup for a cancelled pending job), 
#13446 (fixed-slot release after stop-with-savepoint).
   
   ### Does this PR need Docs?
   
   - [x] No. This PR only adds engine E2E coverage.
   
   ### Does this PR need any UT/E2E?
   
   - [x] Yes. This PR is the E2E coverage.
   


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