Repository navigation
Description
Symptom
After an R session restart, starting the Posit Assistant chat backend can fail indefinitely with:
A Posit Assistant update is in progress. Please try again in a moment.
even though no update is running. Retrying never helps; the chat pane just never becomes ready. The same underlying condition also produces the "R Session Error" / "previous R session terminated abnormally" dialog after the restart.
Observed on the e2e server shard in run 31839732347 (chat-user-skills.test.ts beforeAll failure), but the mechanism is a product bug any server user can hit by restarting R while the assistant is active.
Root cause
installLock() in SessionChat.cpp names this session's in-use lock file (pai/locks/sessions/<ownerId>.lock) with module_context::activeSession().id(). That id is stable across R session restarts, so the replacement rsession process uses the same lock file name as its predecessor.
ChatInstallLock.hpp documents the actual requirement: "ownerId: unique per rsession process."
Normally the predecessor exits and releases the lock before the replacement starts the backend. But when the predecessor process outlives the restart (the restart-with-live-agent wedge family, see #18394), it keeps holding and heartbeating the link-based lock, so it is never stale. The replacement then can never acquire "its own" lock:
chat_start_backendfails withsystem error 37 (No locks available)onpai/locks/sessions/<session-id>.lock, whichacquireInUseForStart()classifies as retryable contention and reports as "A Posit Assistant update is in progress".- The same leaked process holds the project source-database lock, so the replacement's
attachToSourceDatabase()fails and logs "The previous R session terminated abnormally", raising the modal "R Session Error" dialog.
In the CI run above, the leaked predecessor (pid 9716) was still alive and logging assistant-agent output 13 minutes after its replacement started; three successive replacement rsessions (pids 9722, 10030, 10143) all failed chat_start_backend on the same lock file over a 2+ minute span.
Fix
Make the InstallLock ownerId unique per process, as the header already requires -- e.g. <session-id>-<uuid> (keeping the session id prefix for attributability). Concurrent in-use holders are already a supported steady state (one lock file per owner), so a replacement coexisting briefly with its leaked predecessor is safe: mutation (update/uninstall) still correctly refuses while either holder lives, and leftover files from dead processes are stale-cleaned by the next mutator.
The leaked-rsession wedge itself is tracked separately (#18394 family); this issue covers the lock collision that turns a transient leak into a permanent assistant outage.
Activity
kevinushey commentedon Aug 14, 2026
Root cause of the leaked predecessor found: rserver double-launched the replacement session during the restart, and the losing rsession was orphaned -- never contacted, never told to exit. Details and rserver-log evidence in #18572. This issue remains the second layer: even with the double-launch fixed, an orphaned predecessor must not be able to permanently block its replacement's chat backend, so the owner-id fix here still applies.
fix rserver double session launch that leaks an orphaned rsession (#1…
Refuse an empty Posit Assistant lock owner id on the mutation path too
Fix Posit Assistant failing to start in a second RStudio instance on …