inverteum opened a new pull request, #13381:
URL: https://github.com/apache/seatunnel/pull/13381
Yes. This is a contribution to Apache SeaTunnel.
### Purpose of this pull request
Reserve a fixed slot on the master while a slot request is in flight, so
concurrent task-group handlers do not fail the job with NoEnoughResource
against a stale heartbeat snapshot.
Fixes #13349.
Each task group gets its own `ResourceRequestHandler`, and the handlers read
the same `WorkerProfile` snapshot. Nothing was reserved between that read and
`RequestSlotOperation`. Several handlers could therefore select one unassigned
fixed slot. The worker accepts one assignment and returns null for the rest.
The losers retry immediately, still against a snapshot that has not caught up,
and under the default `REJECT` schedule strategy the job fails even though
enough fixed slots were free.
We now reserve the selected fixed slot (worker address + slot id) until the
request succeeds, returns no slot, fails, or the lease expires.
`preCheckWorkerResource` skips slots that are already reserved. The lease is
two minutes, the same length as Hazelcast's default operation call timeout, so
a lost callback cannot hold the slot. The cached profile is applied before the
lease is dropped, so a concurrent handler sees that assignment first.
Dynamic-slot workers are unchanged and are not reserved. `WorkerProfile`
serialization is unchanged. There is no new configuration option.
### Does this PR introduce _any_ user-facing change?
Yes, on the unreleased `dev` branch. No configuration key, default, REST
field, or public API changes. A fixed-slot job (`dynamic-slot: false`) that
submits several task groups at once can now take those slots when the cluster
has enough free fixed slots, instead of failing with `NoEnoughResource` because
concurrent handlers all read one stale heartbeat snapshot. Dynamic-slot
behavior is unchanged.
### How was this patch tested?
Added cases in `ResourceRequestHandlerTest`:
- `inFlightFixedSlotReservationHidesSlotsFromConcurrentHandlers`: four
fixed-slot requests stay in flight against a snapshot that still lists every
slot as free. A fifth handler fails with `NoEnoughResource` and does not send
another `RequestSlotOperation`. Completing the four requests assigns four
distinct slots and clears the leases.
- `nullSlotResponseReleasesReservationSoRetryCanSendAgain`: a null slot
still retries three times, and the lease is gone afterward.
- `failedSlotRequestReleasesFixedSlotReservation`: a failed request releases
the lease.
- `dynamicSlotRequestDoesNotReserveFixedSlot`: a dynamic-slot worker is not
leased.
- `expiredFixedSlotReservationDoesNotHideTheSlot`: a lease whose deadline
has passed no longer hides the slot.
JDK 17:
```
./mvnw -pl seatunnel-engine/seatunnel-engine-server -am test
-Dtest=ResourceRequestHandlerTest,ResourceManagerTest -DfailIfNoTests=false
-DskipITs -Dskip.spotless=true -Dlicense.skipAddThirdParty=true
```
Tests run: 30, Failures: 0, Errors: 0. BUILD SUCCESS.
```
./mvnw -pl seatunnel-engine/seatunnel-engine-server -am test
-Dtest=FixSlotResourceTest -DfailIfNoTests=false -DskipITs -Dskip.spotless=true
-Dlicense.skipAddThirdParty=true
```
Tests run: 2, Failures: 0, Errors: 0. BUILD SUCCESS.
```
./mvnw -pl seatunnel-engine/seatunnel-engine-server spotless:check
```
BUILD SUCCESS.
No new E2E case. This is master-side selection state, and the unit tests
above cover it. The full reactor `./mvnw test` was not run.
### Check list
* [ ] 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/developer/new-license.md)
* [ ] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR.
* [ ] If you are contributing the connector code, please check that the
following files are updated:
1. Update
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
and add new connector information in it
2. Update the pom file of
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
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]