Repository navigation
fix(supervisor): prune stale tombstones on TID collision and shutdown socket errors - #16176
Liang-Psych wants to merge 1 commit into
Conversation
… socket errors On Linux, thread IDs share the PID number space, so kill(pid, 0) can succeed for a worker thread that recycled a dead supervisor's PID, while a crashed supervisor may never unlink its socket. Both facts together blind the pruning logic and leave permanent tombstones. - showRunningSupervisors now requires the socket to exist and, on Linux only, the PID holder to be the kcserver binary (/proc comm) - handleShutdownAction drops the registry entry when shutdown fails with ENOENT/ECONNREFUSED instead of keeping the dead entry - add supervisorLiveness unit tests (run under the existing harness) Fixes posit-dev#16167
|
Heads-up for reviewers: the 4 failing checks ( Could a maintainer please kick off the full suite with secrets so the new |
|
Follow-up for reviewers/users hitting this on self-hosted Server: I published the ops-side companion as MIT-licensed scripts — kallichore-watchman (session culler + orphan-socket sweeper, audit-first, zero dependencies beyond docker/curl). It encodes the same triple gate from this PR (socket existence + |
|
Thanks for this contribution! With this change an abnormal termination gets handled correctly in my testing:
I've migrated this PR to #16224 for refinement and testing. |

Fixes #16167.
Root cause (verified in a Linux Docker deployment)
Two defects combine into permanent tombstones:
isProcessAliveuseskill(pid, 0). On Linux, thread IDs share the PID number space, so it succeeds for a worker thread (e.g.tokio-rt-worker) that recycled a dead supervisor's PID — auto-prune is skipped.handleShutdownActioncallsremoveByPidonly on the success path. When the socket is already gone (ENOENT), execution jumps tocatch, the entry is never removed, and Shut Down always fails the same way.Worst case: a supervisor killed with
kill -9/OOM never unlinks its socket, so bothexistsSyncandkill(pid, 0)return true simultaneously.Changes (
extensions/positron-supervisor)showRunningSupervisorsnow prunes via newisSupervisorAlive(pid, socketPath):kill(pid, 0)+ socket must exist + on Linux only,/proc/<pid>/commmust bekcserver(zero-dependency,pidfd_openwould need native bindings).handleShutdownActiondrops the registry entry when shutdown fails withENOENT/ECONNREFUSED(conservative: timeouts on live supervisors still keep the entry).src/test/supervisorLiveness.test.ts(4 cases) for the existing harness.Verification
tsc --noEmitclean on the extension; eslint not runnable in this sandbox (no local binary, registry blocked) — CI lint will cover it./proccomm behavior verified empirically in a CentOS 7 container: worker thread reads astokio-rt-worker, live supervisor askcserver.