zhuxiangyi opened a new issue, #18311:
URL: https://github.com/apache/dolphinscheduler/issues/18311
### Search before asking
- [x] I had searched in the issues and found no similar issues.
### What happened
When stopping a running workflow instance from the Web UI, the workflow can
remain in `READY_STOP` and the task instance can remain `RUNNING_EXECUTION`
even though the worker logs report that the process tree was killed
successfully.
In the affected case, the worker process tree was similar to:
```text
sudo -u airflow -i /tmp/dolphinscheduler/exec/process/136/136.sh
bash --login -c /tmp/dolphinscheduler/exec/process/136/136.sh
/bin/bash /tmp/dolphinscheduler/exec/process/136/136.sh
python3 success_file_check.py ...
```
The worker logged:
```text
Begin killing task instance, processId: 30448
All processes already terminated.
Successfully killed process tree by SIGINT, processId: 30448
```
But `ps` still showed the task process tree alive afterwards.
### What you expected to happen
The worker should not report kill success while killable child processes are
still alive. It should continue to send the kill signal to child processes that
the tenant user can operate on, even if the root-owned `sudo` parent returns
`Operation not permitted` for `kill -0`.
### How to reproduce
1. Run a shell task as a tenant through `sudo -u <tenant> -i`.
2. Let the shell script start a long-running child process, for example a
Python script that sleeps or polls in a loop.
3. Configure the tenant login shell/profile so `sudo -u <tenant> -i kill -0
<pid>` can emit stderr even with exit code 0, for example readonly variable
warnings from `/etc/profile.d`.
4. Stop the workflow instance from the Web UI.
5. Observe that the worker can mark the process tree as already terminated
while child processes remain alive.
### Anything else
Root cause:
- `ProcessUtils.isProcessAlive` treats every exception from
`OSUtils.exeCmd("kill -0 <pid>")` as "not alive".
- `AbstractShell` throws `ExitCodeException` when stderr is non-empty, even
if the command exit code is 0.
- `kill -0` returning `Operation not permitted` means the process exists but
cannot be signalled by the current user, not that the process has exited.
The fix should distinguish alive, not-alive, and no-permission states when
checking PIDs before sending kill signals.
### Version
3.4.1 and current dev
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
--
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]