zhangshenghang opened a new issue, #13350: URL: https://github.com/apache/seatunnel/issues/13350
### 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), #13349 (snapshot-based selection), #12985 (admission). ### What happened `ResourceRequestHandler.requestSlotWithRetry()` attaches a `whenComplete` callback to the aggregate future and, inside that callback, recursively calls `requestSlotWithRetry(...).get()`. The callback is not asynchronous: `org.apache.seatunnel.engine.common.utils.concurrent.CompletableFuture.whenComplete()` delegates directly to `java.util.concurrent.CompletableFuture.whenComplete`, so the callback runs on the thread that completes the future. For a Hazelcast invocation future, that is a Hazelcast operation/response thread. Calling `.get()` there blocks the completion thread while a new round of remote slot requests is issued. ### Code path [`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) The blocking call is here: ```java requestSlotWithRetry(needRequestIndexes, retryTimes - 1, tags).get(); ``` [`CompletableFuture.java#L100-L104`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/utils/concurrent/CompletableFuture.java#L100-L104) `MAX_RETRY_TIMES` is hard-coded to 3 and there is no delay, backoff, or jitter between attempts: [`ResourceRequestHandler.java#L67`](https://github.com/apache/seatunnel/blob/5e0e9c8e3f5c8b892df4392ca7567a06ea7f3dff/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/resourcemanager/ResourceRequestHandler.java#L67) ### Impact - A slot request that needs retries occupies a Hazelcast completion/operation thread for the duration of the retry round (remote invocation latency, possibly up to the invocation timeout). - Under a burst of task-group requests or a slow/unresponsive worker, many completion threads can be blocked at once, delaying unrelated Hazelcast operations and master scheduling (including heartbeats and state transitions). - The retry loop does not sleep or re-read a fresh worker snapshot between attempts, so it can burn all three attempts in the same stale window and fail the request even though the cluster state changes milliseconds later. - This is especially visible in fixed-slot mode because retries are the normal mechanism for resolving over-selection; in dynamic mode the first request usually succeeds. ### Expected behavior - Retry asynchronously: chain the next attempt with `thenCompose`/`whenCompleteAsync` on a dedicated executor, or schedule it on the resource manager's scheduler with backoff. - Never block a Hazelcast completion thread waiting for another Hazelcast invocation. - Make the number of attempts and the backoff configurable, and include the attempted workers in the failure message. ### Suggested fix direction 1. Replace the recursive `.get()` with an asynchronous retry chain: `getAllOfFuture(requestSlots(indexes)).thenCompose(...)`, and schedule the next attempt with `thenComposeAsync` on a dedicated executor (or with the existing scheduled executor) instead of calling `.get()`. 2. Add a small backoff/jitter between attempts; do not block the completing thread and do not busy-loop. 3. Make the retry count and backoff configurable rather than hard-coded `MAX_RETRY_TIMES = 3`. 4. Add a test with a fake resource manager that rejects the first two attempts and assert that (a) the request eventually succeeds, (b) the completing thread is not blocked, and (c) the retry attempts are visible in metrics. ### 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]
