SEPURI-SAI-KRISHNA opened a new pull request, #13343:
URL: https://github.com/apache/seatunnel/pull/13343

   Yes, glad to contribute to Apache SeaTunnel.
   
   ### Purpose of this pull request
   
   Closes #13319.
   
   With `task_execution_thread_share_mode` set to `ALL`, or `PART` for tasks 
that share threads, `TaskExecutionService.submitThreadShareTask` mapped a task 
whose `init()` failed to `null` and then added it to `threadShareTaskQueue`, a 
`LinkedBlockingDeque`, which threw a `NullPointerException`. The tasks after it 
were neither queued nor reported done, so the completion latch of the task 
group, which counts all its tasks, never reached zero. The group never 
finished: `finishExecution` did not run, the context stayed in 
`executionContexts`, a redeploy of the location was skipped as "already exists 
and is active", and the job hung with the NPE in the log instead of the error 
of `init()`.
   
   Changes, in `submitThreadShareTask` only:
   
   - Every task is either queued or reported done with `taskDone`. A task whose 
`init()` fails records the error and is done, as before. Each task after a 
failure or a cancellation is now done without being initialized, and nothing is 
queued for it.
   - The latch therefore reaches zero, `finishExecution` removes the context, 
and the group completes `FAILED` with the error of `init()`. The tasks already 
queued before the failure are cancelled through the existing `cancelAllTask` 
path, as for a failure while running.
   
   `deployLocalTask` is unchanged. Rolling back a published context when the 
submission itself throws is the scope of #12218, which changes the code after 
this method and does not conflict with it. The default mode `OFF` (blocking 
workers) is not affected.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. In thread-share mode, a task that fails to initialize now fails its 
task group with the error of `init()`, and the job fails or restores its 
pipeline as for any task failure, instead of hanging. No option, default or API 
changes.
   
   ### How was this patch tested?
   
   - `TaskExecutionServiceTest#testThreadShareTaskInitFailureCompletesTheGroup` 
deploys a group of three thread-share tasks in `PART` mode through the real 
`TaskExecutionService`, with the first or the second task failing `init()`. It 
checks that the group completes `FAILED` with the `init()` error, that no task 
after the failing one is initialized, that the context is removed from 
`executionContexts`, and that a second `deployTask` for the same location is 
not skipped as active: it returns success and publishes a context with the new 
execution id. With the `TaskExecutionService` of dev, both cases fail: 
`deployLocalTask` completes exceptionally with the `NullPointerException` from 
`LinkedBlockingDeque.add`.
   - Mutation checks: without `taskDone` for the tasks after a failure, both 
cases time out waiting for the group result; a redeploy over a location that is 
still active is caught by the execution id assertion ("skipping redeploy" in 
the log).
   - All 22 tests of `TaskExecutionServiceTest` pass.
   - `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 documented behaviour changes)
   * [x] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR. (not needed: no incompatible change)
   * [ ] If you are contributing the connector code, please check that the 
following files are updated: (not a connector change)
   


-- 
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]

Reply via email to