You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/09/05 16:20:09 UTC
[I] [Improve][Zeta] Define a two-phase admission contract so queued jobs do not retain a fully initialized JobMaster [seatunnel]
DanielLeens opened a new issue, #12119:
URL: https://github.com/apache/seatunnel/issues/12119
## Description
This is a design task for the job admission path. It is not a regression report.
Verified at `dev` commit `97d461bc0773399d632fd078735736ecd44f5f0b`:
- `CoordinatorService.submitJob()` (`CoordinatorService.java:1374`) constructs `new JobMaster(...)` (`:1419`), calls `init()`, and only then enqueues (`pendingJobQueue.put`, `:1450`). The master-switch restore path does the same (`:1106` -> `:1137` -> `:1158`).
- `JobMaster.init()` (`JobMaster.java:230-322`) acquires classloaders (`:257`), restores the DAG, may run cluster-side sink save-mode handling when `SAVEMODE_EXECUTE_LOCATION == CLUSTER` (`:274-285`), builds the physical plan (`:293`), creates the checkpoint manager (`:319`), and releases the acquired classloader references in `finally` (`:313-314`).
What a queued job retains today: the initialized `LogicalDag`/`PhysicalPlan`, `CheckpointCoordinator` objects, and futures. It does not retain `DefaultClassLoaderService` reference counts, and it holds no checkpoint threads (schedulers create workers on demand). Retained plan objects can still keep shared cached loaders alive in `cacheMode`.
Constraint that rules out the simple reorder: `pendingJobSchedule()` calls `jobMaster.preApplyResources()` (`CoordinatorService.java:422`; `JobMaster.java:505/514`), and `preApplyResourcesForAll` (`:646-662`) sizes the slot request by enumerating `physicalPlan.getPipelineList()`. The plan must exist before the resource check, so "build the `JobMaster` after the check" is circular.
Semantics that would move if initialization is deferred: configuration and plugin-load errors and cluster-side save-mode effects currently surface before the submit acknowledgement; a deferred `init()` must surface them through job status rather than lose them.
## Expected outcome
- A two-phase admission contract: (1) a durable acceptance record (ids, config/artifact digests, enqueue sequence, priority, version, master epoch); (2) plan construction, either built once with the derived slot request persisted and the heavy objects dropped while queued (accepting a re-plan on admission), or a lightweight resource description that does not need the full plan.
- Explicit rules for error timing, pending-job query and cancel, restore, and acceptance semantics.
- Legacy `JobStatus` unchanged: queued jobs project to `PENDING`, admitted jobs to `INITIALIZING`.
- Heap per queued job measured before and after under `WAIT` with a backlog of 10x capacity.
--
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: commits-unsubscribe@seatunnel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Improve][Zeta] Define a two-phase admission contract so queued jobs do not retain a fully initialized JobMaster [seatunnel]
Posted by "DanielLeens (via GitHub) via commits" <co...@seatunnel.apache.org>.
DanielLeens commented on issue #12119:
URL: https://github.com/apache/seatunnel/issues/12119#issuecomment-7210304347
### Measured heap cost of queued jobs under WAIT
@JeremyXin Thanks for volunteering and outlining the two-phase admission design. I ran a focused measurement on Apache SeaTunnel 3.1.0 in an isolated two-process Zeta cluster (one Master, one Worker, two static slots, JDK 11.0.27 with G1 and a 768 MiB Master heap). A running job occupied both slots. I submitted FakeSource-to-Console jobs through the normal client path in batches of 100, 250, 500, and 1,000. I checked that the submitted jobs were still `PENDING` before and after each measurement. Each workload was run twice on fresh JVMs. Each measurement is the median of three post-GC heap readings, compared with the warmed baseline with no pending jobs.
| Parallelism | Extra Master heap at 100 pending | At 500 pending | At 1,000 pending | Average per job at 1,000 pending |
| --- | ---: | ---: | ---: | ---: |
| 1 | 5.9–7.9 MiB | 27.7–29.7 MiB | 53.6–54.4 MiB | 54.9–55.7 KiB |
| 16 | 12.1–13.2 MiB | 58.0–58.1 MiB | 111.8 MiB | 114.4–114.5 KiB |
The live heap histogram showed a 128-byte shallow size per `JobMaster`. The measured increase includes execution plans and other data retained while jobs are queued. After cancellation, the 1,000 additional `JobMaster` instances were collected in each run, and total heap usage remained above the baseline. A before-and-after implementation test would be needed to quantify the savings from deferring initialization. The parallelism-16 jobs were too large to start in the two-slot test cluster, so that case measures the cost of a larger queued execution plan.
At roughly 6–13 MiB for 100 pending jobs in this test, I would defer the admission lifecycle change for deployments with modest backlogs and sufficient Master heap headroom. I would prioritize it if production regularly reaches queues of around 1,000 jobs, or if heavier execution plans and measured post-GC heap or GC pressure show a material impact at lower queue depths.
Jeremy, could we close this issue for now and defer implementation? We can reopen it with production queue-depth and Master-heap evidence if that warrants prioritizing the change.
<!-- stip12119-wait-heap-20261127 -->
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Improve][Zeta] Define a two-phase admission contract so queued jobs do not retain a fully initialized JobMaster [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12119:
URL: https://github.com/apache/seatunnel/issues/12119#issuecomment-6415640995
Thanks @JeremyXin for volunteering and for starting with the acceptance record rather than only moving `JobMaster.init()`. I checked current `dev` (`4f5e3293740`): normal `CoordinatorService.submitJob()` still initializes `JobMaster` before inserting the pending entry, and `preApplyResources()` sizes a request from the physical plan. #12201 is an open, separate PR for preserving WAIT queue order and deferring initialization during *master recovery*; it does not settle the normal submission/admission contract in this issue.
Please take the design of that remaining submission path forward here. Before an implementation PR, make three decisions explicit: (1) what a successful submit acknowledgement means after plugin/configuration errors and cluster-side save-mode work move to the job lifecycle; (2) how a lightweight demand descriptor is derived and checked against the later physical plan without silently changing the requested slots; and (3) how a durable record/version fences cancel-before-init and master failover so a late initializer cannot resurrect or double-admit a job. Keep existing `JobStatus` values, and specify upgrade/restore behavior for jobs accepted before the new record exists.
Please coordinate the recovery slice with #12201's author and let #12985 consume the same admission record rather than defining a second one. A focused design update and tests for those error-timing, cancellation, replay, and 10x-backlog heap cases are the next review gate. I added the `improve`, `Zeta`, and `design` labels. I tried to assign this design task to you, but GitHub did not accept the assignment; the `help wanted` label remains so the work is visible.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Improve][Zeta] Define a two-phase admission contract so queued jobs do not retain a fully initialized JobMaster [seatunnel]
Posted by "CryoThrust (via GitHub)" <gi...@apache.org>.
CryoThrust commented on issue #12119:
URL: https://github.com/apache/seatunnel/issues/12119#issuecomment-5556420197
For the two-phase boundary, I suggest treating the acceptance record as the source of truth and making the heavy `JobMaster` strictly reconstructible from it:
- Persist an immutable record before `JobMaster.init()` with `jobId`, config/artifact digests, derived resource descriptor (pipeline/slot requirements), enqueue sequence, priority, engine version and `masterEpoch`. The record should have an explicit lifecycle such as `ACCEPTED -> INITIALIZING -> RUNNING` (or `FAILED/CANCELLED`).
- A cancellation of an `ACCEPTED` job should atomically mark a tombstone/version before initialization starts. Restore and the admission worker must check that version so a late initializer cannot resurrect a cancelled job.
- If a queued job is re-planned when admitted, compare the resulting resource descriptor and digests with the acceptance record. A mismatch should transition to a visible initialization failure, not silently change scheduling order or resource accounting.
- Keep configuration/plugin-load errors in the job lifecycle for deferred initialization, while preserving the submit acknowledgement as “accepted for scheduling”; callers should not interpret it as “configuration initialized successfully”.
- On master restore, rebuild only the lightweight record/index first, then let the admission loop construct plans in persisted queue order. This provides a clean hand-off to #12120 rather than reintroducing eager `JobMaster` creation during recovery.
The contract tests should cover cancel-before-init, duplicate admission after failover, digest/version mismatch on re-plan, and an initializer finishing after a newer cancellation/update. These cases are where the two-phase design can otherwise leak a queued job back into the running set.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Improve][Zeta] Define a two-phase admission contract so queued jobs do not retain a fully initialized JobMaster [seatunnel]
Posted by "JeremyXin (via GitHub)" <gi...@apache.org>.
JeremyXin commented on issue #12119:
URL: https://github.com/apache/seatunnel/issues/12119#issuecomment-6399222065
@DanielLeens
I’d like to work on this issue. Here is an initial design for discussion:
1. Persist a lightweight acceptance record when a job is submitted, including its job ID, immutable configuration/artifact identity, enqueue order, and master epoch. Keep queued jobs visible as PENDING.
2. Separate resource-demand derivation from full JobMaster initialization. Derive and persist the demand needed for admission, then release planning objects while the job waits. Construct the execution plan and checkpoint state when resources become available.
3. Before starting the job, verify that the reconstructed plan matches the accepted configuration and resource demand. Treat a mismatch or initialization error as a visible job failure.
4. Make cancellation and master recovery operate on the durable record. Use its version/epoch to prevent a cancelled job from being initialized later or a job from being admitted twice.
I would preserve existing JobStatus values and test submission error timing, cancel-before-admission, failover during admission, and memory use with a backlog under WAIT.
I see that #12201 addresses queue ordering and lazy initialization during recovery. I’d build on that work while keeping this issue focused on the broader submission and admission lifecycle. I’m happy to take this on.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Improve][Zeta] Define a two-phase admission contract so queued jobs do not retain a fully initialized JobMaster [seatunnel]
Posted by "SEZ9 (via GitHub) via commits" <co...@seatunnel.apache.org>.
SEZ9 commented on issue #12119:
URL: https://github.com/apache/seatunnel/issues/12119#issuecomment-7230193763
@JeremyXin thanks for the design outline. Your four points (lightweight acceptance record, demand derivation separated from full `JobMaster` initialization, plan verification before start, and cancel/recovery on the durable record) are still the right shape for this issue.
On the measurement posted above (SeaTunnel 3.1.0, one Master and one Worker, 768 MiB Master heap):
- **Cost at 100 pending jobs:** about 5.9–13.2 MiB of extra Master heap, depending on parallelism.
- **Cost at 1,000 pending jobs:** 53.6–54.4 MiB at parallelism 1 and 111.8 MiB at parallelism 16, or roughly 55–115 KiB per queued job.
- **What it does not show:** how much deferring initialization would save. That needs a before-and-after implementation test, so the benefit of the two-phase contract is still unquantified.
Given those numbers, I agree with deferring implementation for now. The cost is modest for small backlogs with heap headroom, and the change touches submit acknowledgement semantics, save-mode timing and failover fencing, which is a lot of contract surface to move without a demonstrated need.
Before closing, two asks:
1. Do you have production or test evidence that would change the priority? That would be queue depths around 1,000 jobs, or heavier execution plans where post-GC Master heap or GC pressure is material at lower depths. If so, please share the queue depth, job parallelism, Master heap size and post-GC readings.
2. If you have no such evidence, are you OK with closing this for now? We can reopen it when that data shows up.
If it is reopened, the review gate stays as already stated. The design update needs to make three decisions explicit:
- what a successful submit acknowledgement means once plugin/configuration errors and cluster-side save-mode work move into the job lifecycle;
- how the lightweight demand descriptor is derived and checked against the later physical plan without silently changing the requested slots;
- how the durable record/version fences cancel-before-init and master failover.
It also needs to keep the existing `JobStatus` values, specify upgrade/restore behavior for jobs accepted before the new record exists, and include tests for error timing, cancellation, replay, and backlog heap with a before/after comparison.
<!-- streview-comment:2672 -->
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org