Repository navigation
protect source recovery ownership and isolate session tests - #18853
Merged
Merged
Conversation
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
had a problem deploying
to
e2e-playwright
September 17, 2026 04:06 — with
GitHub Actions
Failure
This was referenced Sep 25, 2026
kevinushey
added a commit
that referenced
this pull request
Sep 26, 2026
…ease it on failed startup - Pin the old socket's inode with a hard link in the two identity tests: Linux reuses a freed inode number at once, so a rebound socket could get the old identity (the Jenkins c++-unit-tests failure). - Set FD_CLOEXEC on the claimed session socket, so a child that outlives a killed session can't make it look alive to the next launch. - Release the claimed stream (socket + pid file) when rsessionMain returns early, i.e. when startup fails after the claim. - Back out the address_in_use comparison change: server sessions no longer reach that retry loop, and enabling it for TCP sessions leaks a listener per retry. Left for #18946. - Drop the NEWS entry: the lockout exists only since #18853 (unreleased). - Drop bindEndpoint()'s cleanup() call, which is a no-op before a claim. Addresses #18941.
kevinushey
added a commit
that referenced
this pull request
Sep 26, 2026
#18944) * don't let a duplicate session launch take over a live session's socket A duplicate rsession launch for the same session unlinked the live session's stream socket before binding its own, then aborted on the source-database lock the live session holds (#18853) and removed the socket it had bound on the way out. The live session was left listening on an unlinked inode, and every recovery launch repeated the abort, so the user could not get back in until the original process was killed. The local stream listener now probes the path before binding and reports it as in use when a process answers, so the duplicate exits after the startup retry window instead of supplanting the live session. On exit it only removes the socket and pid file if they are still the ones it bound (compared by device and inode), so a supplanted session cannot take its successor's socket with it either. rserver could launch the duplicate because a request error landing between recording a pending launch and learning its pid erased the entry (the #18572 guard needs a pid); the entry is now kept while the launch function is in flight. The address_in_use retry comparison in the session's listener startup never matched asio's system-category error, and waitWithTimeout now reports the last error that kept it waiting. Addresses #18941 * claim the session socket first, bind before probing, keep launches through both request outcomes Fold in the stronger structure from a parallel take on #18941: - claimSessionStream() binds the session's local stream first thing in rsessionMain, before any state a second process for the same session would share; a duplicate exits at once with a warning naming the owning process. The listener is split into bindEndpoint() and start(). - claimLocalStream() binds without unlinking and probes only on EADDRINUSE, so of two processes racing for a missing path the kernel picks the winner. stop() runs cleanup() before closing the acceptor, so an exiting session unlinks its path while still listening. - The rserver pending-launch entry is kept through request successes as well as errors while the launch function runs, and endLaunching() matches on launch time so it never clears a newer entry. - rstudio-tests gives each run its own RS_SESSION_TMP_DIR: sessions no longer take over a socket another test run is listening on. - Tests adapted and extended (claimLocalStream, bindEndpoint-before-start). Addresses #18941 * fix socket tests on linux, keep the claimed socket from children, release it on failed startup - Pin the old socket's inode with a hard link in the two identity tests: Linux reuses a freed inode number at once, so a rebound socket could get the old identity (the Jenkins c++-unit-tests failure). - Set FD_CLOEXEC on the claimed session socket, so a child that outlives a killed session can't make it look alive to the next launch. - Release the claimed stream (socket + pid file) when rsessionMain returns early, i.e. when startup fails after the claim. - Back out the address_in_use comparison change: server sessions no longer reach that retry loop, and enabling it for TCP sessions leaks a listener per retry. Left for #18946. - Drop the NEWS entry: the lockout exists only since #18853 (unreleased). - Drop bindEndpoint()'s cleanup() call, which is a no-op before a claim. Addresses #18941.
This branch was successfully 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.
Intent
Improve the source-recovery behavior discussed in #18744 and #18746 with source-database ownership checks, test-launcher isolation, and failure handling for headless script startup. Sessions using different lock types must not mistake each other's live recovery data for abandoned documents.
Approach
--run-scripton initialization errors with a nonzero exit status and abnormal cleanup, so scripts cannot continue after source-database ownership checks fail. Log the error and exit directly to avoid Windows modal fatal-error dialogs.Desktop/Server recovery namespaces and persistent-document sharing remain follow-up work in #18746. This change does not establish an atomic ownership-transfer protocol for older binaries. A moved, released symlink lock can still prevent advisory takeover; the documents are preserved and a link-based session can recover them.
Automated Tests
Validated on macOS arm64:
rsessionandrstudio-core-tests.git diff --checkpassed.Additional ad hoc Windows launcher checks used stub session executables: 4 passed, 1 Unix-only check skipped. These covered inherited state, combined scopes, repeated invocations, and temporary-directory creation failure. GUID-generation failure was also verified to prevent startup in both session scopes.
git diff --checkpassed.Focused Windows startup regressions passed through
rstudio-tests.bat --scope r --filter script-startup: 2 test cases, 9 assertions passed, with no warnings or skips. The success case executes its script; a source-database initialization failure exits with status 1 without executing the script. These tests use isolated child environments and clear inherited POSIX locale settings on Windows.For this validation,
RScriptCallbacks.cppwas rebuilt and relinked against existing local Windows build objects in an isolated directory. This does not validate the complete PR's Windows lock/recovery changes. The new startup tests have not been run on macOS or Linux, and the full unrelated test suite has not been run.QA Notes
rsessionandrtest scopes with inherited data/config settings; each scope should use fresh temporary state and preserve the user's existing state.Documentation
Added a NEWS entry linked to #18744.
Checklist
NEWS.mdentry.