zhangshenghang opened a new issue, #13353:
URL: https://github.com/apache/seatunnel/issues/13353

   ### 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: #12087 / #11663 (worker and slot autoscaling), 
#12985 (fixed-slot admission), #11665 (worker resource view).
   
   ### What happened
   
   In fixed-slot mode, every slot is created with a synthetic 
`ResourceProfile`: `CPU.of(0)` and `Memory.of(Runtime.maxMemory() / slotNum)`.
   
   
[`DefaultSlotService.java#L290-L303`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L290-L303)
   
   All task-group requests currently use an empty `ResourceProfile`:
   
   
[`ResourceUtils.java#L99-L112`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/ResourceUtils.java#L99-L112)
   
   So today the slot's resource profile is effectively ignored: 
`slot.getResourceProfile().enoughThan(empty)` is always true. `slotNum` is only 
a concurrency permit count, not a CPU or memory quota. This creates two 
problems:
   
   1. **The advertised resource model is not honest.** A slot says 
`CPU{core=0}` and `heap=maxMemory/slotNum`, but nothing enforces either. A 
single task in a slot can consume the entire worker heap and any number of 
threads; `slot-num` cannot prevent an OOM.
   2. **The model breaks as soon as real resource requests are enabled.** 
`ResourceUtils` already has `TODO custom resource size` at line 101. If a task 
requests `CPU > 0`, no fixed slot can ever satisfy it because every slot has 
CPU 0. If a task requests more than `maxMemory/slotNum`, no slot can satisfy it 
even when the worker has plenty of free heap, because there is no aggregation 
across slots and no fragmentation handling.
   
   The slot is also not an isolation unit: `DeployTaskOperation` uses 
`SlotContext` only to reach `TaskExecutionService`, and the `slotID` does not 
affect task scheduling or thread/memory limits:
   
   
[`DeployTaskOperation.java#L49-L54`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/operation/DeployTaskOperation.java#L49-L54)
   
   
[`SlotContext.java#L23-L33`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/SlotContext.java#L23-L33)
   
   ### Impact
   
   - Operators cannot use fixed slots as a resource quota; `slot-num` only 
bounds concurrent task groups.
   - A job with heavy tasks can exhaust worker heap even when the slot count is 
low; a `slot-num` sized by CPU does not protect memory.
   - The moment a connector or a future "custom resource size" feature asks for 
real CPU/heap, fixed-slot allocation fails for every task, with a confusing 
`NoEnoughResourceException`.
   - The REST/diagnostic resource view advertises CPU 0 and a heap slice that 
is neither reserved nor enforced (see the observability issue).
   
   ### Expected behavior
   
   Choose one of two coherent contracts:
   
   1. **Make slots real resources.** Account CPU and heap per slot, enforce the 
per-slot heap/thread budget where possible, and support aggregating slots for a 
request that exceeds one slot (or reject it with a clear diagnostic).
   2. **Keep slots as concurrency permits, but say so.** Rename/document the 
semantics, stop advertising CPU=0 and a fake heap slice as if they were quotas, 
and expose `slot-num` as a task-group concurrency limit in REST/diagnostics.
   
   ### Suggested fix direction
   
   - If option 1: add a per-slot resource budget to 
`TaskExecutionService`/deployment, check it at deploy time, and make 
`selectBestMatchSlot` aggregate or reject large requests deterministically.
   - If option 2: change `initFixedSlots()` to use the node resource only for 
reporting (or omit it), document `slot-num` as a concurrency limit, and align 
the REST/metrics wording with the actual behavior.
   - Add a test that a task requesting `CPU.of(1)`/large heap either runs under 
a slot that can satisfy it or fails with an explicit "fixed slot cannot satisfy 
resource profile" message, not a generic `NoEnoughResourceException`.
   
   ### 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]

Reply via email to