Skip to content

Posit Assistant: chat backend permanently reports "update is in progress" after an R session restart #18571

Closed

Description

@kevinushey

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_backend fails with system error 37 (No locks available) on pai/locks/sessions/<session-id>.lock, which acquireInUseForStart() 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

  1. self-assigned this
    on Aug 14, 2026
  2. kevinushey commented on Aug 14, 2026

    @kevinushey
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions