{"record":{"id":"fbd2cb54c61bb9c5","repo":"apache/dolphinscheduler","slug":"cancel-application-error-fbd2cb","errorCode":null,"errorMessage":"cancel application error","messagePattern":"cancel application error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java","lineNumber":225,"sourceCode":"        }\n\n        String others = jupyterParameters.getOthers();\n        if (StringUtils.isNotEmpty(others)) {\n            args.add(others);\n        }\n\n        args.add(JupyterConstants.INJECT_PATHS);\n        args.add(JupyterConstants.PROGRESS_BAR);\n        return args;\n    }\n\n    @Override\n    public void cancelApplication() throws TaskException {\n        // cancel process\n        try {\n            shellCommandExecutor.cancelApplication();\n        } catch (Exception e) {\n            throw new TaskException(\"cancel application error\", e);\n        }\n    }\n\n    @Override\n    public AbstractParameters getParameters() {\n        return jupyterParameters;\n    }\n\n}\n","sourceCodeStart":207,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java#L207-L235","documentation":"JupyterTask.cancelApplication() wraps any exception from shellCommandExecutor.cancelApplication() (which kills the spawned jupyter process) into TaskException 'cancel application error'. It fires during task cancellation when the underlying process handle cannot be signalled or destroyed.","triggerScenarios":"Task is being killed and shellCommandExecutor.cancelApplication() throws — process already exited, PID no longer exists, OS permission denial sending the kill signal, or an internal executor exception during cancel.","commonSituations":"Killing a task whose jupyter process already finished (race), worker user lacking permission to kill a process started under another user/container, zombie processes, or OS-level restrictions in containers without SIGKILL capability.","solutions":["Inspect the wrapped stack trace; if the process already exited the cancel race is benign and can be retried/ignored.","Verify the worker user can signal child processes (especially in Docker/Kubernetes containers).","Check for orphaned jupyter/nbconvert processes on the worker and kill them manually.","Upgrade to a version where cancelApplication handles already-dead processes gracefully."],"exampleFix":"// before\n} catch (Exception e) {\n    throw new TaskException(\"cancel application error\", e);\n}\n// after\n} catch (Exception e) {\n    log.warn(\"failed to cancel jupyter application, process may already be dead\", e);\n    throw new TaskException(\"cancel application error: \" + e.getMessage(), e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static boolean isBenignCancelError(TaskException e) {\n    Throwable c = e.getCause();\n    return c != null && (c.getMessage() != null && c.getMessage().contains(\"No such process\"));\n}","tryCatchPattern":"try {\n    jupyterTask.cancelApplication();\n} catch (TaskException e) {\n    if (isBenignCancelError(e)) {\n        log.info(\"process already terminated; cancel is a no-op\");\n    } else {\n        log.warn(\"failed to cancel jupyter process\", e);\n    }\n}","preventionTips":["Run all tasks and the worker under the same user/container security context so kills are permitted.","Avoid container runtimes that strip kill capabilities (SIGTERM/SIGKILL) from the worker.","Monitor for zombie jupyter processes and clean them periodically.","Treat cancel races (process already exited) as expected in retry/kill logic."],"tags":["jupyter","cancel","process-kill","dolphinscheduler"],"backgroundTag":"process-cancel-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}