qiuyanjun888 commented on issue #18311:
URL:
https://github.com/apache/dolphinscheduler/issues/18311#issuecomment-4739634666
I have thinked about the design, @ruanwenjun @SbloodyS , could you please
take a look and give some suggestions?
# Task Process Boundary Design
## Design
- Introduce `TaskProcessBoundary` for local physical tasks.
- Create the boundary before launching the task process.
- Store boundary metadata in task runtime metadata.
- Kill the boundary directly during task cancellation.
- Report kill success only after the boundary is verified as terminated.
## Boundary Types
1. `SystemdScopeTaskProcessBoundary`
- Preferred on Linux hosts with systemd.
- Start task with a dedicated transient scope:
```bash
systemd-run --scope --unit dolphinscheduler-task-<taskInstanceId> --uid
<tenant> <task-script>
```
- Kill the whole scope:
```bash
systemctl kill --kill-who=all --signal=SIGTERM <scope>
systemctl kill --kill-who=all --signal=SIGKILL <scope>
```
2. `ProcessGroupTaskProcessBoundary`
- Fallback when systemd is unavailable.
- Start task in a new session/process group:
```bash
setsid <task-launch-command>
```
- Kill the whole process group:
```bash
kill -TERM -<pgid>
kill -KILL -<pgid>
```
3. `LegacyPidTreeTaskProcessBoundary`
- Compatibility fallback only.
- Keep current `pstree` based behavior when no stable boundary is
available.
## Runtime Metadata
Store supported fields only:
- `boundaryType`
- `workerHost`
- `tenantCode`
- `rootPid`
- `processStartTime`
- `processGroupId`
- `sessionId`
- `systemdScopeName`
- `cgroupPath`
## Kill Semantics
- `success=true`: the boundary is terminated or already gone.
- `success=false`: the boundary cannot be terminated or cannot be verified.
- Do not report kill success only because the kill request was accepted.
- Do not add new user-visible kill states in this design.
--
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]