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

   Yes, I am contributing this engine E2E guard to Apache SeaTunnel.
   
   ## What this adds
   
   `DynamicSlotWorkerReplacementIT` pins the dynamic-slot lifecycle of a Zeta 
job whose only worker is lost and then replaced.
   
   The fixture is one in-JVM master-only member plus two in-JVM workers, all 
with `dynamic-slot: true` and `slot-num: 1`. The job is a STREAMING `FakeSource 
-> Console` pipeline with parallelism 1, so it needs exactly two task groups: 
the split enumerator and the fused reader/writer task group.
   
   1. The job is submitted while the first worker is the only worker, so every 
task group is placed on it. The worker must own two dynamic slots and the 
distributed ownership map must contain exactly two records, both pointing at 
that worker.
   2. A replacement worker is started and observed as registered **before** the 
first worker is shut down. It must still own no slot while the first worker is 
healthy.
   3. The first worker is shut down. The task groups fail, the job restores, 
and the replacement worker must own exactly two dynamic slots of that job.
   4. The distributed ownership map must again contain exactly two records, 
both pointing at the replacement worker; the resource manager's assigned-slot 
view must also contain exactly those two slots and no capacity on the dead 
worker. No dynamic slot identity may be handed out twice.
   5. The footprint has to stay stable for a 3 s window while the restored job 
runs.
   6. Cancelling the restored job must reach `CANCELED`, release both dynamic 
slots, leave no unassigned slot in the fixed pool, remove the ownership record, 
and release the job master.
   
   No production code, public API, configuration option or default value is 
changed.
   
   ## Why this is a boundary with real regression risk
   
   In `dynamic-slot: true` mode a worker creates a slot per task group instead 
of slicing a fixed pool, so the slot's worker address is the only identity of 
the resource a task group holds. The `assignedSlots` map on the worker and the 
distributed ownership map are the only records of what is in use.
   
   Member removal follows a different path from job cancellation and master 
failover: task groups fail, the pipeline restores, and the resource request is 
re-issued while the dead worker's records may still be present. A regression 
there either keeps capacity/ownership records for a member that cannot serve 
them (so later restores or jobs see a slot that cannot be reached) or re-uses a 
slot identity that is still assigned (so two task groups share one slot 
context). Both are silent: the restored job may still appear `RUNNING` while 
capacity accounting is wrong.
   
   ## Why existing coverage does not reach it
   
   - `DynamicSlotNoCapacityCheckIT` documents that one dynamic-slot job is 
granted a slot per task group without a capacity rejection; it never loses a 
worker and never inspects release, ownership or a replacement.
   - `DynamicSlotLifecycleIT` (#13759) covers release across sequential job 
boundaries on one live node, not a member loss.
   - `DynamicSlotMasterFailoverIT` (#13760) covers the master switch while the 
worker survives and asserts that the same dynamic slots are reused; it never 
replaces the worker.
   - `ClusterFaultToleranceIT` / `SplitClusterFaultToleranceIT` shut down 
workers but pin fixed slots and only assert output/status, never dynamic slot 
identity, ownership or the resource manager's assigned slots.
   - No existing engine E2E observes dynamic-slot ownership after the owning 
worker has left the cluster and a replacement has joined.
   
   ## Determinism
   
   The cluster and the client run inside the test JVM. The job is submitted 
while the first worker is the only worker, so placement is not a guess. The 
replacement worker is registered and observed before the shutdown, so the 
restore has capacity immediately and does not depend on a later registration 
event. Every slot observation is a read of the worker profile, the distributed 
ownership map or the resource manager, and each is polled until it converges 
rather than guessed with a sleep. The source is a long-running streaming 
`FakeSource`, so the job cannot finish while the assertions run.
   
   ## Verification
   
   ```bash
   export 
JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
   ./mvnw -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
     -DskipUT=true -DskipIT=false -Dit.test=DynamicSlotWorkerReplacementIT \
     -DfailIfNoTests=false verify
   ```
   
   Five consecutive green runs on pristine `origin/dev` `1e7e29a75b` with the 
engine-server jar `sha256 
e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`: 20.1 s, 23.5 
s, 23.6 s, 23.5 s and 26.0 s. `spotless:check` is bound to `validate` and 
passed in every run.
   
   ```bash
   ./mvnw -o -q -pl seatunnel-ci-tools -Dtest=ImportClassCheckTest 
-DfailIfNoTests=false test  # exit 0
   git diff --check                                                             
              # exit 0
   ```
   
   ## Negative control
   
   Skipping `assignedSlots.remove(...)` in `DefaultSlotService#releaseSlot` (a 
scratch engine-server build, mutation reverted afterwards) makes the new test 
fail after 146 s with:
   
   ```
   a cancelled job must release every dynamic slot it owned:
   [SlotProfile{... slotID=1 ...}, SlotProfile{... slotID=2 ...}]
   ==> expected: <true> but was: <false>
   ```
   
   The pristine engine-server jar was reinstalled (`sha256 e3687ea...`) and a 
green run repeated before opening this PR.
   
   ## Notes
   
   No GitHub issue: the contract holds on current `dev`, so this PR adds the 
missing regression guard only. The source and sink are plain fixtures; every 
assertion is about the engine's slot scheduling, ownership accounting and job 
lifecycle, never about connector, transform or SQL semantics.
   


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