Repository navigation
fix rserver double session launch that leaks an orphaned rsession - #18573
Merged
Merged
Conversation
An error on a request still in flight to an exiting session no longer erases the pending-launch record of its freshly spawned replacement. Erasing it let the next connection-retry recovery pass launch a second replacement one second later; both booted, the second re-bound the session stream socket, and the first became an unreachable orphan that was never told to exit -- still holding the project source-database lock and the Posit Assistant install lock. Also moves core::system::isProcessRunning out of the Linux-only branch of PosixSystem.cpp: it is plain POSIX and was declared unconditionally in the header, but failed to link on macOS. Addresses #18572.
The in-use lock file was named by activeSession().id(), which is stable across session relaunches, so an orphaned predecessor rsession held a live lock under its replacement's own name and every chat_start_backend in the replacement failed with a spurious 'A Posit Assistant update is in progress'. The owner id is now '<session-id>-<uuid>'. Addresses #18571.
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:40 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:40 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:41 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:41 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:43 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:43 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:43 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:43 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:43 — with
GitHub Actions
Inactive
kevinushey
had a problem deploying
to
e2e-playwright
August 15, 2026 00:43 — with
GitHub Actions
Failure
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:45 — with
GitHub Actions
Inactive
kevinushey
temporarily deployed
to
e2e-playwright
August 15, 2026 00:45 — with
GitHub Actions
Inactive
RStudio E2E - all platforms1 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
kevinushey
added a commit
that referenced
this pull request
Aug 18, 2026
kill(pid, 0) fails with EPERM when the probed process exists but is owned by another user -- exactly what rserver's privilege-dropped request threads see when probing a live rsession on a root-launched multi-user server. The liveness guard from #18573 read that as "not running" and erased the pending-launch record on request errors, so the #18572 double-launch stayed reproducible in precisely the deployment class it targets (dev and e2e servers share a uid with their sessions and were unaffected). Only ESRCH proves absence; count EPERM as alive. Addresses #18572.
This was referenced Sep 11, 2026
This was referenced Sep 22, 2026
This branch was previously deployed
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.
Fixes #18572. Fixes #18571.
An R session restart on RStudio Server could leak an orphaned rsession that runs forever. Root-caused from the rserver debug log of e2e run 31839732347: after the old session acked
suspend_for_restartand exited, rserver launched two replacements one second apart. An RPC still in flight to the exiting session died with EOF, andhandleRpcErrorunconditionally removed the pending-launch record of the first replacement (spawned 37 ms earlier); the retrying/rpc/ping's one-second launch throttle then spawned a second one. Both booted, the second re-bound the session stream socket, and the first became unreachable -- never contacted, never told to exit, holding the project source-database lock (surfacing the "previous R session terminated abnormally" dialog) and the Posit Assistant install lock, and reacting to shared user-prefs changes indefinitely.Two fixes:
ServerSessionManager::removePendingLaunchno longer erases a pending launch on the request-error paths while the launched process is still alive: a request failing for the context says nothing about the health of a separately launched, still-booting session. The existing safety nets still clear the entry -- the SIGCHLD process tracker (rpcs can fail with "unable to connect to service" for 30s+ after session suspend #18208) when the pid dies, andlaunchSession's one-minute window otherwise. Custom session launchers never record a pid and keep the old clear-on-error behavior. (Also movescore::system::isProcessRunningout of the Linux-only branch ofPosixSystem.cpp; it is plain POSIX, was declared unconditionally in the header, and failed to link on macOS.)<session-id>-<uuid>). It was the bare session id, which is stable across relaunches, so an orphaned predecessor held a live lock under its replacement's own name and everychat_start_backendin the replacement failed with a spurious, never-clearing "A Posit Assistant update is in progress." With the per-process id, even an orphan can only make mutations (update/uninstall) refuse -- correctly, since the install genuinely is in use -- while backend starts coexist, which is the supported multi-session steady state.Follow-ups noted on #18572 and deliberately not included: the success path (
handleProxyResponse) has a much narrower variant of the same race, and an rsession could self-detect a supplanted stream socket and exit.Verification:
SessionManagerTest.RequestErrorKeepsPendingLaunchOfLiveProcess,RequestErrorClearsPendingLaunchOfDeadProcess,RequestErrorClearsPendingLaunchWithoutRecordedPid;ChatInstallLock.SameOwnerIdCollidesWithLivePredecessor.rstudio-tests --scope rsession: 418/418 pass.--scope rserver: allSessionManagerTestand proxy tests pass (theSqliteDBActiveSessionStorageTestfailures are environmental on this machine and identical on main's build).