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

   Yes — glad to contribute this to Apache SeaTunnel.
   
   Closes #13356.
   
   ### What Problem Does This PR Solve?
   
   `ResourceRequestHandler#request()` returns a future that is completed only 
from `addSlotToCacheMap()`, which runs once per arriving slot result and 
completes the future when every requested slot has been collected. For an empty 
resource profile list that callback never runs at all:
   
   1. `request()` builds an empty index list.
   2. `requestSlots([])` returns nothing, so `getAllOfFuture([])` resolves 
immediately.
   3. The `whenComplete` callback sees no error and `stillNeedRequestIndexes()` 
is empty, so no retry is attempted.
   4. `completableFuture` is never completed.
   
   The future is left pending with no exception and no log, so anything joining 
it blocks indefinitely. `ResourceManager#applyResources` forwards the future 
straight to its caller, so an empty list reaching it from the pending-job 
scheduler stalls that master's queue with no diagnostic beyond a stuck thread.
   
   ### What Changed
   
   An empty request is completed with an empty list, through the existing 
`completionStarted` guard so there remains exactly one completion path:
   
   ```java
   if (resourceProfile.isEmpty()) {
       if (completionStarted.compareAndSet(false, true)) {
           completableFuture.complete(Collections.emptyList());
       }
       return completableFuture;
   }
   ```
   
   I chose "empty request is a valid no-op" over the alternative the issue also 
offers — rejecting with `IllegalArgumentException` at the API boundary — 
because `applyResources` is reached defensively from the scheduler and an empty 
pipeline is not obviously a programming error. A completed empty result keeps 
callers that pass an empty list working instead of turning a silent hang into a 
new exception path.
   
   ### How Was This Patch Tested?
   
   Built and run locally — JDK 11.0.32, Maven 3.8.4, `seatunnel-engine-server` 
module:
   
   ```
   Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
     - in 
org.apache.seatunnel.engine.server.resourcemanager.ResourceRequestHandlerTest
   ```
   
   (7 before, 1 added.) `spotless:apply` reports no changes to the committed 
files.
   
   The new test is load-bearing, not merely passing — removing the guard turns 
it red:
   
   | Mutation | Result |
   | --- | --- |
   | drop the empty-request guard | 1 failed |
   | none | 8 passed |
   
   The test asserts `request.isDone()` immediately rather than joining the 
future. That is deliberate: a test for a never-completing future must fail fast 
rather than hang the suite, which is also why it does not need a timeout.
   
   Added to the existing `ResourceRequestHandlerTest` rather than a new class, 
reusing its `IndexedRetryResourceManager` so the test can also assert the 
request never reached a worker:
   
   - the future is done as soon as `request()` returns
   - the result is an empty list
   - `requestCount` is 0 — an empty request must not contact any worker
   
   ### Compatibility
   
   - No new or changed configuration options, no changed defaults, no signature 
change.
   - Non-empty requests take exactly the path they took before: the guard 
returns early only for an empty `resourceProfile`.
   - Uses the `completionStarted` CAS that already guards completion, so this 
cannot double-complete the future or race with `addSlotToCacheMap()`.
   
   ### Docs
   
   No documentation change: this is an internal resource-manager contract with 
no user-facing option, command or output.
   
   ### Check list
   
   * [x] Code changed are covered with tests, or it does not need tests for 
reason
   * [x] If any new Jar binary package adding in your PR, please add License 
Notice according [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
 — no new dependency
   * [x] If necessary, please update the documentation to describe the new 
feature — not user-visible
   * [x] If you are contributing the connector code, please check that the 
following files are updated — not a connector change
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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