zhangshenghang opened a new pull request, #13516:
URL: https://github.com/apache/seatunnel/pull/13516
Yes — I am contributing this change to Apache SeaTunnel.
### Purpose of this pull request
Fixes #13515.
A client retry of the same submission must never turn into a second
execution. Today `CoordinatorService#submitJob` performs the "is this job id
already known" check on the caller (RPC) thread, but publishes the new
`JobMaster` from the asynchronous admission task:
1. caller thread: `getJobMaster(jobId) != null` — sees only a `JobMaster`
already put into `pendingJobQueue` / `runningJobMasterMap`;
2. admission task: deserialize the job, `new JobMaster(...)`, `init()`, and
only then `pendingJobQueue.put(...)` + complete the submission future.
Two submissions of the same id that arrive before step 2 finishes both pass
step 1, both build a `JobMaster`, and both are enqueued and scheduled. The
worker's `TaskExecutionService` then sees the same `TaskGroupLocation` already
active and skips the redundant deploy, so the duplicate `PhysicalPlan` keeps
operating on state owned by the first one. The data path looks fine (all rows
are written once), but the competing state machines lose the terminal
transition: the job stays `RUNNING` forever, holding its slots and checkpoint
coordinator, and only a manual cancel or a master restart clears it.
The window is real: admitting one job deserializes the DAG, builds the
physical plan and creates the checkpoint manager, which takes tens of
milliseconds — exactly the window a network-timeout retry, an operator
re-running the command, or two submitters using the same explicit job id can
hit.
### Fix
Admission of one job id is now atomic. `submitJob` claims the job id in an
in-flight submission registry (`ConcurrentHashMap#putIfAbsent`) before
scheduling the admission task:
- the first caller owns the admission;
- a concurrent duplicate resolves with the owner's submission future,
matching the behavior the coordinator already defines for an already published
job ("currently running; no need to submit again") instead of starting a second
admission;
- the registry entry is removed when admission finishes (success or
failure), so later retries are handled by the normal running/history checks;
- `clearCoordinatorService` fails the registered futures and clears the map,
so a retry against the next active master cannot wait forever on an entry whose
admission task was cancelled before it started.
No public API, configuration option, or data format changes.
### Tests
New E2E `ConcurrentDuplicateSubmissionIT` (in-process Zeta cluster, dynamic
slots, bounded FakeSource -> LocalFile, 200 rows):
- 8 clients, each with its own `JobConfig` but the same explicit job id, are
released by one barrier and submit simultaneously;
- every submission must resolve (no caller failure for losing the race) and
every proxy must point at the submitted id;
- the job must reach `FINISHED` within 120 s — a duplicate admission leaves
it `RUNNING` forever;
- the sink must contain exactly 200 lines, i.e. exactly one execution;
- after the job has finished, a late re-submission of the same id must
resolve to the finished job or fail fast with the duplicate diagnostic, and
must not add rows. This also proves the in-flight entry is released on the
success path.
Verification on this branch (JDK 17):
- `ConcurrentDuplicateSubmissionIT` passed 3 times back to back (about 10 s
each).
- Negative control: with only the `CoordinatorService` change reverted and
the engine module reinstalled, the same test fails in 142 s with `expected:
<FINISHED> but was: <RUNNING>` after writing all 200 rows — the exact
production symptom.
- `./mvnw spotless:apply` and the repository `ImportClassCheckTest` pass for
the changed modules.
The test only uses the connectors as an observable fixture: the contract
under test is engine admission/lifecycle, so there is no connector-, transform-
or SQL-specific boundary here.
### Compatibility and risk
- Duplicate submissions of a job id that is still being admitted now share
one submission future instead of racing. Submissions of a running/pending job
and submissions of a finished job id keep their existing behavior.
- The registry is keyed by job id and is bounded by the number of concurrent
admissions; entries are removed in a `finally` block and cleared on coordinator
step-down.
--
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]