zhangshenghang opened a new issue, #13346: URL: https://github.com/apache/seatunnel/issues/13346
### Search before asking - [x] I searched existing issues and PRs before filing this report. - [x] This report is based on source analysis at commit [`5e0e9c8e3f`](https://github.com/apache/seatunnel/commit/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff); line numbers may drift on `dev`. - [x] Related existing work: #9589, #11437, #12125. This issue is specifically about ownership/liveness reconciliation, not the admission/queue ordering in #12985. ### What happened A fixed slot is assigned on the worker and recorded on the master in two separate steps. There is no lease, acknowledgement, idempotency key, or reconciliation: 1. The master sends `RequestSlotOperation(jobId, ResourceProfile)`. 2. The worker assigns a slot (or returns `null`) and returns a `SlotAndWorkerProfile` snapshot. 3. Only much later, when the pipeline reaches `SCHEDULED`, the master writes the slot-to-task mapping into `ownedSlotProfilesIMap` via `ResourceUtils.applyResourceForPipeline()` -> `setOwnedSlotProfiles()`. If step 3 does not happen, or if the response from step 2 is lost and the master retries, the worker can end up holding a slot that the master has no profile for. With `dynamic-slot: false` there is no elastic capacity and no worker-side expiry, so the slot is lost until the worker restarts. ### Failure modes (verified in code) - **Lost response + retry can double-assign.** `RequestSlotOperation` is not idempotent, and `ResourceRequestHandler` retries up to three times when a request fails: [`ResourceRequestHandler.java#L107-L173`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/ResourceRequestHandler.java#L107-L173) If the worker executed the assignment but the response was lost, the retry obtains a second slot. The first slot remains assigned to the same job with a valid allocation sequence, but no master-side profile records it. - **Master crash between assignment and persistence.** `preApplyResources()` only keeps futures in `PhysicalPlan`: [`JobMaster.java#L586-L605`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java#L586-L605) The only persistence point is the pipeline `SCHEDULED` transition: [`ResourceUtils.java#L67`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/ResourceUtils.java#L67) A crash in this window leaves the worker holding slots for a job that the new master can no longer release or reuse (the new master has no `SlotProfile`). - **No reconciliation on the worker or master side.** `DefaultSlotService.releaseSlot()` requires the exact `SlotProfile` (slot ID + allocation sequence + owner job ID) and rejects anything else: [`DefaultSlotService.java#L205-L235`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L205-L235) `JobMaster.cleanJob()` does not scan worker-side assignments for `jobId`: [`JobMaster.java#L1041-L1046`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java#L1041-L1046) `AbstractResourceManager.syncExistingWorkerProfiles()` only registers profiles; it does not compare them with `ownedSlotProfilesIMap` or release orphans: [`AbstractResourceManager.java#L116-L144`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/AbstractResourceManager.java#L116-L144) - **A failed release is best-effort.** `releasePipelineResource()` logs and returns after retries: [`JobMaster.java#L998-L1039`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java#L998-L1039) A transient worker/IMap failure therefore permanently shrinks a fixed pool. ### Impact - Fixed-slot capacity silently decreases after response loss, master crash, or a failed release. - Later jobs under `WAIT` wait forever; under `REJECT` they fail, with no indication that the cluster is holding orphan slots. - Operators cannot release the orphan slots without restarting the worker, because the required allocation sequence exists only in the lost `SlotProfile`. ### Reproduction - Drop the `RequestSlotOperation` response after the worker has assigned the slot (e.g. network fault injection or a test worker that assigns and then fails the response), and let the master retry. The worker ends with two assigned slots for the same job; the master records one. - Kill the active master between the job-level `preApplyResources()` and the pipeline `SCHEDULED` transition. On the new master, the worker still reports the slots as assigned, `getUnassignedSlots()` is lower than `slot-num`, and no job owns the difference. ### Expected behavior - Every assigned fixed slot must have a master-side owner record that survives master failover, or a worker-side lease that expires when the owner stops renewing it. - Slot assignment should be idempotent for the same logical request (job + task group + attempt), or the master must be able to enumerate and release assignments by `jobId`. - Reconciliation should run at least on resource-manager initialization and on job completion, and should release worker assignments whose owner job is terminal. ### Suggested fix direction 1. Add a per-assignment idempotency key (jobId + taskGroupLocation + attempt) to `RequestSlotOperation`, so a retried request returns the already-assigned slot instead of allocating a second one. 2. Persist the pre-applied `taskGroupLocation -> SlotProfile` mapping immediately (the same record used by `ownedSlotProfilesIMap`, or a dedicated `PRE_APPLIED` map), so a new master can release/reuse it. 3. Add a worker-side `releaseSlotsForJob(jobId)` operation, used on job completion/cancel as a safety net, independent of the master's per-slot profiles. 4. On resource-manager initialization, compare each worker's assigned slots with the union of `ownedSlotProfilesIMap` and the job registry, and release assignments whose owner job is no longer known or is terminal. 5. Add fault-injection tests for lost assignment responses and master crashes in the pre-apply window. ### SeaTunnel version `dev` (analyzed at `5e0e9c8e3f`). ### Zeta or Flink or Spark Version Zeta. ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
