You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "shenshichao163-oss (via GitHub)" <gi...@apache.org> on 2026/08/15 09:06:36 UTC

[PR] fix: stop flink job error by using flink cancel command before process kill [dolphinscheduler]

shenshichao163-oss opened a new pull request, #18554:
URL: https://github.com/apache/dolphinscheduler/pull/18554

   ## What this PR does
   
   Fixes the issue where stopping Flink tasks from the DolphinScheduler page fails to send proper kill signals, causing errors in worker node logs.
   
   ### Root Cause
   
   When a user clicks "Stop" on a Flink task, DolphinScheduler uses the generic `AbstractCommandExecutor.cancelApplication()` method, which sends OS-level kill signals (SIGINT → SIGTERM → SIGKILL) to the process tree. This approach does not properly stop the Flink job — it kills the shell process but fails to gracefully cancel the Flink application, leading to:
   - Error logs in worker nodes
   - Flink jobs not being properly terminated
   - Resource leaks in the YARN/Kubernetes cluster
   
   ### Fix
   
   Override `cancelApplication()` in `FlinkTask` to:
   
   1. **First attempt graceful cancellation** using the `flink cancel <appId>` command (via `FlinkArgsUtils.buildCancelCommandLine()`). This method already existed in the codebase but was never called.
   2. **Fall back to process-level kill** (the parent class implementation) if the Flink cancel command fails, times out (30s), or no appIds are available.
   
   ### Changes
   
   - **`FlinkTask.java`**: Added `cancelApplication()` override that tries `flink cancel` first, then falls back to `super.cancelApplication()`
   - Added imports: `TaskException`, `TaskCallBack`
   
   ### Issue Link
   
   Fixes #16789
   
   ### Before
   
   Stopping a Flink task from the page → `AbstractCommandExecutor.cancelApplication()` → `ProcessUtils.kill()` (SIGINT/SIGTERM/SIGKILL) → Flink job not properly cancelled, worker logs show errors
   
   ### After
   
   Stopping a Flink task from the page → `FlinkTask.cancelApplication()` → `flink cancel <appId>` (graceful) → if fails → `super.cancelApplication()` (process kill as fallback)
   
   ### Checklist
   
   - [x] I have searched the [issues](https://github.com/apache/dolphinscheduler/issues) of this repository and believe that this is not a duplicate.
   - [x] I have checked that this modification does not cause CI to fail.
   - [x] I will sign the Apache CLA if required.
   - [x] The code follows the projects coding style.


-- 
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@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: stop flink job error by using flink cancel command before process kill [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS closed pull request #18554: fix: stop flink job error by using flink cancel command before process kill
URL: https://github.com/apache/dolphinscheduler/pull/18554


-- 
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@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: stop flink job error by using flink cancel command before process kill [dolphinscheduler]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #18554:
URL: https://github.com/apache/dolphinscheduler/pull/18554#issuecomment-5301521177

   Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   


-- 
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@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org