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

   Yes — this change contributes to **Apache SeaTunnel** (Zeta engine E2E 
coverage).
   
   ### Motivation
   
   In `dynamic-slot: true` mode (the engine default), a worker does not hand 
out slices of a
   pre-partitioned pool: it creates a fresh slot for every task group a job 
asks for and records the
   job as the slot owner. While the job runs, those slots are persisted in
   `engine_ownedSlotProfilesIMap` together with the task group they serve, so a 
promoted master can
   adopt them after a failover instead of asking the worker for new ones.
   
   That adoption is a real engine contract, and breaking it is silent. The 
worker keeps running the
   pre-failover task groups; the restored job still reaches `RUNNING`, still 
checkpoints and still
   processes data. The only observable damage is on the worker: the old slots 
stay assigned while the
   new ownership record points at freshly created slots. Dynamic slots are 
discarded rather than
   returned to a fixed pool, so `assignedSlots` is the only record of what is 
still in use, and the
   drift accumulates with every master switch until the advertised resource 
view - and any
   capacity-based scheduling built on it - is wrong.
   
   ### Change
   
   Test-only addition under 
`seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base`:
   
   - `DynamicSlotMasterFailoverIT` starts two master nodes and one worker. The 
worker is explicitly
     configured with `dynamic-slot: true` and `slot-num: 1`; the streaming 
fixture
     (`FakeSource -> Console`, parallelism 1, Console has no committer) creates 
exactly two task
     groups, the split enumerator and the fused reader/writer, so the job owns 
two dynamic slots.
   - Before the failover the test waits for two completed checkpoints, then 
pins the worker's assigned
     slot ids and the persisted ownership record (one entry per task group, at 
those ids).
   - The active master is shut down while the worker keeps the task groups and 
slots. After the
     standby takes over, the test requires the job to return to `RUNNING`, a 
new checkpoint to
     complete on the promoted master, and the assigned dynamic slot id set to 
be **exactly the same
     set** as before the failover. A second checkpoint after the observation 
proves the adopted tasks
     keep running through those slots.
   - Cancelling the restored job must release every dynamic slot 
(`assignedSlots` empty), must not
     recycle released dynamic slots into a fixed pool (`unassignedSlots` stays 
empty), must leave no
     ownership record, and must release the job master.
   
   The fixture reads one bounded split and then stays idle, so the job remains 
`RUNNING` with both
   task groups deployed until the test cancels it. No production code, public 
API, SPI, configuration
   option, default value, state or file format is touched.
   
   ### Existing coverage gap
   
   - #11458 and its E2E #13101 cover **fixed-slot** reuse after a master 
failover, and only assert the
     restored job owns the same **number** of slots; they never compare slot 
identities.
   - The existing split-cluster failover tests run with dynamic slots but never 
inspect which slots
     the restored job owns, so a re-allocation that leaves the old slots behind 
still passes them.
   - #13759 (open) covers the release of dynamically created slots across 
sequential job boundaries on
     one master, not their adoption across a master switch.
   - No existing engine E2E compares the dynamic slot id set before and after a 
master failover.
   
   I searched open and closed PRs/issues for `dynamic slot failover`, `dynamic 
slot master`,
   `slot reuse master failover` and `slot ownership failover` before opening 
this PR; the only
   same-area results are the fixed-slot work above and #13759, neither of which 
covers this contract.
   
   ### Verification
   
   ```bash
   export JAVA_HOME=<jdk17>
   mvn -o -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
spotless:apply
   mvn -o -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
       verify -DskipUT=true -DskipIT=false 
-Dit.test=DynamicSlotMasterFailoverIT -DfailIfNoTests=false
     Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
   mvn -o -pl seatunnel-ci-tools test -Dtest=ImportClassCheckTest
     Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
   git diff --check
   ```
   
   Five consecutive green runs on `dev` `1e7e29a75b` with the pristine 
`engine-server` jar
   (sha256 `e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`), 
17.6 s-18.0 s each.
   Observed on a green run:
   
   ```
   Job 1179643039258247169 owns dynamic slots [1, 2] before failover
   Job 1179643039258247169 completed checkpoint 5 after failover
   ```
   
   Negative control: temporarily making `JobMaster#getReusableSlot` return 
`null` (mutation reverted,
   pristine jar reinstalled) fails the new test in 16.4 s with exactly the leak 
this contract guards:
   
   ```
   the promoted master must reuse the still-active dynamic slots instead of 
requesting new ones;
   before: [1, 2], after: [1, 2, 3, 4] ==> expected: <[1, 2]> but was: <[1, 2, 
3, 4]>
   ```
   
   ### Checklist
   
   - [x] Test-only change; no production behavior modified.
   - [x] No new dependencies; the fixture uses the existing `FakeSource` and 
`Console` connectors.
   - [x] Deterministic waits only (no fixed sleeps for the contract assertions).
   - [x] Follows the repository formatting and import rules; 
`ImportClassCheckTest` passes.
   


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