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

   ### 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: #12947 (partial allocation rollback), #13344 
(pre-applied slot cleanup).
   
   ### What happened
   
   `ResourceRequestHandler.request()` returns a future that is completed inside 
`addSlotToCacheMap()` when `resultSlotProfiles.size() == 
resourceProfile.size()`. If the requested `resourceProfile` list is empty, no 
slot result ever calls `addSlotToCacheMap()`, so the completion condition is 
never evaluated and the returned future never completes.
   
   ### Code path
   
   
[`ResourceRequestHandler.java#L98-L105`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/ResourceRequestHandler.java#L98-L105)
   
   
[`ResourceRequestHandler.java#L229-L244`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/ResourceRequestHandler.java#L229-L244)
   
   Trace for `resourceProfile = []`:
   
   1. `request()` builds an empty `requestIndexes`.
   2. `requestSlotWithRetry([], 3, tags)` calls `requestSlots([])`, which 
returns an empty list.
   3. `getAllOfFuture([])` completes immediately.
   4. The `whenComplete` callback sees no error and `stillNeedRequestIndexes()` 
returns an empty list, so it does nothing.
   5. `completableFuture` is never completed.
   
   `AbstractResourceManager.applyResources()` forwards this future directly:
   
   
[`AbstractResourceManager.java#L187-L199`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/AbstractResourceManager.java#L187-L199)
   
   ### Impact
   
   - Any caller of the public `ResourceManager#applyResources(jobId, emptyList, 
tags)` API gets a future that never completes, blocking a thread that joins it.
   - If a future code path produces a job/pipeline with no task groups (or a 
caller uses `applyResources` defensively with an empty list), the pending 
scheduler can block on `preApplyResources()` forever, which stalls all queued 
jobs on that master.
   - No exception or log is produced; the failure is silent and only visible as 
a stuck thread.
   
   ### Expected behavior
   
   - An empty request is a valid no-op: return a completed future with an empty 
`List<SlotProfile>`.
   - Alternatively, reject it with a clear `IllegalArgumentException` at the 
API boundary, but do not return a never-completing future.
   
   ### Suggested fix direction
   
   1. In `request()`, if `resourceProfile.isEmpty()`, return 
`CompletableFuture.completedFuture(Collections.emptyList())` (or complete 
`completableFuture` immediately).
   2. In `requestSlotWithRetry()`, handle the "no indexes" case explicitly and 
complete the outer future.
   3. Add a unit test for `applyResources(jobId, Collections.emptyList(), 
null)` that asserts the future completes within a bounded time with an empty 
result.
   
   ### 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