fix: stop flink job error by using flink cancel command before process kill - #18554
Open
shenshichao163-oss wants to merge 1 commit into
Open
fix: stop flink job error by using flink cancel command before process kill#18554shenshichao163-oss wants to merge 1 commit into
shenshichao163-oss wants to merge 1 commit into
Conversation
…s kill - Override cancelApplication() in FlinkTask to first attempt graceful cancellation via 'flink cancel <appId>' command - Fall back to process-level kill (SIGINT/SIGTERM/SIGKILL) if flink cancel fails or appIds are unavailable - This fixes the issue where stopping Flink tasks from the page would fail to send proper kill signals, causing errors in worker node logs Fixes apache#16789
shenshichao163-oss
requested review from
Gallardot,
SbloodyS and
caishunfeng
as code owners
August 15, 2026 09:06
|
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) |
3 tasks
SbloodyS
requested changes
Aug 16, 2026
SbloodyS
left a comment
Member
There was a problem hiding this comment.
Please follow PR template and fill in the form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:Fix
Override
cancelApplication()inFlinkTaskto:flink cancel <appId>command (viaFlinkArgsUtils.buildCancelCommandLine()). This method already existed in the codebase but was never called.Changes
FlinkTask.java: AddedcancelApplication()override that triesflink cancelfirst, then falls back tosuper.cancelApplication()TaskException,TaskCallBackIssue 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 errorsAfter
Stopping a Flink task from the page →
FlinkTask.cancelApplication()→flink cancel <appId>(graceful) → if fails →super.cancelApplication()(process kill as fallback)Checklist