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

   ### Purpose of this pull request
   
   Yes, I am contributing to Apache SeaTunnel.
   
   Part of #13346. This PR closes the "master crash between assignment and 
persistence" window that the issue lists as a fixed-slot capacity leak.
   
   A fixed slot is assigned on the worker first. The master only records the 
slot-to-task ownership when the pipeline reaches `SCHEDULED` 
(`ResourceUtils.applyResourceForPipeline`). If the master fails between the 
successful pre-apply and that transition, the new master has no `SlotProfile` 
for the assignment: it can neither reuse it on restore nor release it on job 
completion. With `dynamic-slot: false` the worker never expires the slot, so 
the capacity is lost until the worker restarts.
   
   What this PR changes:
   
   - After a successful `JobMaster.preApplyResources(...)`, the exact 
`TaskGroupLocation -> SlotProfile` mapping is written to 
`ownedSlotProfilesIMap` immediately, grouped per pipeline, instead of waiting 
for `SCHEDULED`.
   - Only profiles of successfully completed allocation futures are persisted. 
Slots reused from the previous master are written again with their existing 
values.
   - The write uses the exact `SlotProfile` (worker, slot id, allocation 
sequence). Reuse validation (`getReusableSlot`/`slotActiveCheck`) and release 
still reject a slot that was meanwhile released and reassigned to another task 
group or attempt, so the early write cannot make a stale mapping acceptable.
   - The early write is best effort: the `SCHEDULED` transition remains the 
enforcing persistence point, so a transient IMap failure here is logged instead 
of failing a job whose slots have already been allocated.
   
   Scope note: this PR addresses the durable-ownership part of #13346 only 
(item 2 of the suggested fix direction). Idempotent allocation requests for 
lost responses (item 1) and worker-side reconciliation by job (items 3/4) are 
not included; they need the allocation-identity/attempt contract discussed in 
the issue thread, and a job-id-only worker-side release would conflict with 
SAVEPOINT restores, which reuse the source job id 
(`ClientJobExecutionEnvironment`).
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Allocation, reuse and release semantics are unchanged; the ownership 
record is written earlier.
   
   ### How was this patch tested?
   
   - `./mvnw -pl seatunnel-engine/seatunnel-engine-server spotless:apply`
   - `./mvnw -pl seatunnel-engine/seatunnel-engine-server 
-Dtest=JobMasterMasterFailoverResourceTest,JobMasterTest -DfailIfNoTests=false 
test` (14 tests passed)
   
   The new `testPreApplyPersistsSlotOwnershipBeforePipelineDeployment` 
pre-applies a fixed-slot job without starting any pipeline and asserts that 
every pipeline already has a persisted `taskGroup -> slot` map whose size 
matches its coordinator + task vertices. The three existing failover tests 
(reuse of active slots, sub-plan restore flag, stale reassigned slot rejection) 
still pass with the mapping now written earlier.
   
   No E2E scenario was added: the failure window is between pre-apply and 
`SCHEDULED`, which the existing E2E allocation tests cannot stop 
deterministically. The embedded-cluster resource tests above exercise the same 
`JobMaster`/`ResourceManager`/fixed-slot `SlotService` path.
   


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