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

   ### 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: #11665 (worker resource view), #12087 / #11663 
(autoscaling), #12985 (fixed-slot admission), #13353 (fixed-slot resource 
model).
   
   ### What happened
   
   In fixed-slot mode, `WorkerProfile.unassignedResource` is initialized to the 
**entire node resource** (`maxMemory` heap, CPU 0) and then decremented by the 
resource of each assigned slot. The actual schedulable capacity, however, is 
the number of **unassigned slots**, not the reported free heap:
   
   - At startup, `unassignedResource` reports the full heap even though the 
only way to use it is through `slot-num` slots.
   - After all slots are assigned, `unassignedResource` may still report a 
small non-zero remainder (integer division of `maxMemory / slotNum`), implying 
capacity that cannot be allocated.
   - `WorkerProfile.profile` and `unassignedResource` report `CPU{core=0}`, 
which is not a meaningful capacity for the node or the slot pool.
   
   REST/diagnostic consumers (overview, worker resource view, pending 
diagnostics) can therefore report "free heap" that the scheduler can never 
assign, while the real constraint (`unassignedSlots`) is a separate field. The 
slot-count fields (`totalSlot`, `unassignedSlot`) are correct for fixed slots, 
but the resource bytes/CPU are not aligned with what the scheduler can actually 
do.
   
   ### Code path
   
   
[`DefaultSlotService.java#L108-L111`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L108-L111)
   
   
[`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)
   
   
[`DefaultSlotService.java#L306-L319`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/service/slot/DefaultSlotService.java#L306-L319)
   
   Slot-count overview:
   
   
[`GetOverviewOperation.java#L77-L89`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/opeartion/GetOverviewOperation.java#L77-L89)
   
   Worker diagnostic:
   
   
[`PendingDiagnosticsCollector.java#L310-L345`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/diagnostic/PendingDiagnosticsCollector.java#L310-L345)
   
   ### Impact
   
   - Capacity dashboards and alerts see free heap/CPU that cannot be used by 
fixed-slot scheduling.
   - Operators may conclude the cluster is under-utilized and submit more work, 
when the real bottleneck is `unassignedSlot == 0`.
   - A pending-job diagnostic may report a resource profile of `cpu=0, 
heap=...` that does not correspond to the slot constraint that actually 
rejected the job.
   - Misleading "free memory" also obscures the difference between "node memory 
not carved into slots" and "slots available for a new job".
   
   ### Expected behavior
   
   - Make the distinction explicit in the model and the API:
     - `schedulableCapacity` = `unassignedSlots.length * slotMemory` for 
fixed-slot workers;
     - `nodeFreeMemory` = actual heap not currently assigned (or omit it);
     - `slotPoolTotal` / `slotPoolFree` as first-class fields;
     - `dynamicSlot` flag, already present in `WorkerResourceDiagnostic`, 
should determine which view is authoritative.
   - REST/UI/diagnostics should show the fixed-slot pool as the capacity that 
matters, not raw heap.
   - CPU should be reported as unknown/not-applicable for fixed slots rather 
than `CPU{core=0}`.
   
   ### Suggested fix direction
   
   1. Add explicit slot-pool capacity fields to `OverviewInfo` / worker 
diagnostic payloads and label them in the REST/UI.
   2. In fixed-slot mode, report `unassignedResource` as either the sum of 
unassigned slot resources or a clearly named "node free" value, not a mixed 
quantity.
   3. Update the pending-job diagnostic to say "no free fixed slot" (with 
`totalSlots`/`freeSlots`/`requiredSlots`) rather than showing an empty resource 
profile.
   4. Add a REST/UI test for a fixed-slot worker with all slots assigned and a 
dynamic-slot worker with the same raw heap, and assert the capacity fields are 
distinguishable.
   
   ### 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