Skip to content

desktop can reclaim a running server session's source database #18744

Closed

Description

@kevinushey

Problem

With no project open, RStudio Desktop and RStudio Server can use the same user data directory. Desktop defaults to advisory file locks, while Server defaults to link-based file locks. Source database recovery checks only the new session's lock type, so Desktop can treat a running Server session as orphaned and rename its sources/session-<id> directory.

The original Server session remains alive but attempts to create a document fail with system error 2 (No such file or directory) when writing <document-id>-contents beneath its original session directory. Existing unsaved documents also move with the directory.

Reproduction

Reproduced on macOS with the local development build:

  1. Start a Server-mode rsession without a project, using a temporary RSTUDIO_DATA_HOME, and create a document.
  2. Keep it running and start a Desktop-mode rsession with a different launcher token, using the same temporary data directory.
  3. Observe that the original sources/session-<server-id> directory is renamed to the Desktop session's ID while the Server process is still alive.
  4. Invoke new_document in the Server session. It fails with ENOENT.

The reproduction invokes the actual RPC with .rs.invokeRpc("new_document", "r_source", "", list(tempName="Untitled")). Giving Desktop a separate RSTUDIO_DATA_HOME prevents the rename and the RPC succeeds.

Related test isolation problem

The rsession C++ scope in the Unix and Windows rstudio-tests launchers initializes a real session without first assigning temporary RStudio data/configuration directories. The R test scope already assigns these directories. Consequently, C++ session tests can interact with an IDE running as the same user. Unscoped Server sessions can also select the same active session ID, and source database initialization currently logs lock contention and continues.

Expected behavior

Source database recovery should recognize both lock types and leave live sessions alone. A session should refuse to reuse a source directory that another process owns. Both C++ and R session tests should use temporary RStudio state.

QA

Verify concurrent Server/Desktop sessions sharing a temporary user data directory in both launch orders. Both should retain their source directories and continue creating documents. Also verify that abandoned directories can still be recovered, that a second process cannot reuse an actively owned session directory, and that the C++ test launcher uses isolated state even when real RStudio data/configuration variables are inherited.

Activity

  1. added theissue type on Sep 9, 2026
  2. self-assigned this
    on Sep 9, 2026
  3. added a commit that references this issue on Sep 25, 2026
  4. kevinushey commented on Oct 5, 2026

    @kevinushey
    CollaboratorAuthor

    Fixed in 2026.10 by #18748 (Desktop now uses the platform default lock type, so both editions agree on how to read each other's locks) and #18853 (source recovery checks both lock types, refuses to reuse a directory another session owns, and the C++ and R test launchers now use isolated data/config directories). The namespace separation follow-up is tracked in #18746.

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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions