SEPURI-SAI-KRISHNA opened a new pull request, #13495:
URL: https://github.com/apache/seatunnel/pull/13495
Yes, glad to contribute to Apache SeaTunnel.
### Purpose of this pull request
Closes #13477.
A sink task registers with the pipeline's aggregated committer in
`SinkFlowLifeCycle.open()` and waits for the result. On the committer's node,
`SinkRegisterOperation` retried the committer lookup 30 times, 2 s apart, while
it threw `TaskGroupContextNotFoundException`. That also happened when the
committer's task group had already ended, for example because the job was being
cancelled, so every retry failed the same way. The sink waited with
`InvocationFuture.join()`, which ignores interrupts, so the cancel could wait
about a minute.
Changes, all in `seatunnel-engine-server`:
- `TaskExecutionService.isTaskGroupEnded(location)`: true when the location
has a finished context and no active one.
- `SinkRegisterOperation`: when the lookup fails and the committer's task
group has ended, it fails at once with an error that names the writer and the
committer. While the committer is not deployed yet (no context at all), it
keeps retrying as before.
- `SinkFlowLifeCycle.registerCommitter()`: waits on a plain future that the
invocation completes, so an interrupt ends the wait.
**Correction to the plan in the issue.** I proposed switching to the
interruptible `get()`. That does not work: in Hazelcast 5.1.7,
`AbstractInvocationFuture.get()` only records the interrupt and keeps parking,
and the invocation completes as interrupted only when it is retried
(`Invocation.handleRetry`), not while the remote operation runs. The third test
below fails with `get()` alone, so the wait goes through a plain future.
**Restore, and a failed cleanup.** A restored committer keeps its
`TaskGroupLocation`. `SubPlan.prepareRestorePipeline` calls
`JobMaster.clearPipelineMetricsForRestore`, which sends
`CleanTaskGroupContextOperation` for each task group of the pipeline before the
pipeline is deployed again. That removes the finished context, so a restored
sink keeps retrying until the new committer is active (second test). Once the
new committer is active, its active context is found first.
The cleanup is best effort: a failure is logged as a warning per task group
and the restore goes on. If the clean of the committer's context failed and
that node is still in the cluster, a restored writer that registers before the
new committer is active now fails at once. Its sink task fails, that restore
attempt fails, and the pipeline is restored again while `job.retry.times`
allows (default 3), which runs the cleanup again. Before this change, such a
writer kept retrying for up to a minute and usually registered once the new
committer was active. If the committer's node left the cluster, its contexts
are gone with it and nothing changes.
**An interrupted writer's request.** When the wait ends on an interrupt, the
`SinkRegisterOperation` already sent keeps running on the committer's node: it
fails at its next attempt once the committer has ended there, and otherwise
retries for up to the usual minute. If a restored committer becomes active at
the same location within that time, the old request registers the writer's task
ID, which the restored writer shares and registers again itself.
`SinkAggregatedCommitterTask` uses the registered IDs only to leave `STARTING`
once every writer has registered and to count closed writers, and never reads
the stored address, so at most it leaves `STARTING` before that writer has
registered itself.
I checked the open PRs that touch these files (#13362, #13343, #13339,
#13338, #11557): none changes `SinkRegisterOperation`, `registerCommitter()` or
`getActiveExecutionContext()`. #13362 changes `SinkFlowLifeCycle.close()`, just
above `registerCommitter()`.
### Does this PR introduce _any_ user-facing change?
Yes. Cancelling a job while a sink registers with a committer that has
already ended no longer waits about a minute, and such a registration fails
with an error that names the writer and the committer. No option, default, API
or state format changes.
### How was this patch tested?
Three tests in `TaskExecutionServiceTest`, which send the real
`SinkRegisterOperation` to the in-process node:
- `testSinkRegisterFailsAtOnceWhenCommitterTaskGroupEnded`: a committer task
group that has finished, so its context is finished and not cleaned.
Registration fails within one retry interval with the new error. On dev it is
still retrying after 10 s.
- `testSinkRegisterWaitsForCommitterRedeployedByRestore`: the committer
ends, its context is cleaned with `CleanTaskGroupContextOperation` as a restore
does, and a new committer is published at the same location 3 s later.
Registration is still waiting after one retry interval, then registers with the
new committer. This passes on dev too; it guards the restore path.
- `testSinkRegisterWaitReturnsWhenWriterThreadIsInterrupted`:
`SinkFlowLifeCycle.open()` registers with a committer that is never deployed,
and its thread is interrupted. `open()` returns with `InterruptedException`
within one retry interval. It fails on dev (`join()`) and with `get()` instead
of `join()`.
I did not add a job-level test. The hang needs the registration to start
just as the committer ends and before the cancel interrupts the sink task, and
a test job cannot pin that window without engine hooks.
`JobExecutionIT.cancelJobTest`, which failed this way in CI, covers the job
path.
- `./mvnw test -pl seatunnel-engine/seatunnel-engine-server` on JDK 17: 744
tests, 0 failures, 0 errors, 5 skipped.
- `TaskExecutionServiceTest` (23), `SinkFlowLifeCycle*Test` and
`SinkAggregatedCommitterTaskTest`: 41 tests, 0 failures.
- `spotless:check`, `git diff --check`.
### Check list
* [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/developer/new-license.md)
(no new jar)
* [x] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs (not needed: no
option or behavior a user configures)
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR. (not needed)
* [ ] If you are contributing the connector code, please check that the
following files are updated: (not a connector)
--
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]