Skip to content

fix(ssh): a wake's fence carries its owner token from the moment the lock exists - #25825

Closed
OrcaWin wants to merge 2 commits into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-wake-fence-atomic
Closed

OrcaWin wants to merge 2 commits into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-wake-fence-atomic

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​77 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​77 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41

ELI5

When Orca restarts a stopped managed server, it first takes a short lock on the host. That lock stops two clients from starting the server at once. If the SSH connection dropped at exactly the moment the lock was created, the host could be left with a lock that nobody could prove was theirs. The next connect then said "An update, rollback or recovery holds this host" and didn't start the server. That lasted until the lock went stale, 20 minutes later. Now the lock records who created it in the same step that creates it, so the client that left it can always clear it.

What Changed

Before:

After:

  • Token written with the lock: the restart claims its random token in memory before taking the lock, and passes it to the lock call. The command that creates the lock writes the token inside it in the same step, on both POSIX and Windows. Whenever the lock exists, it carries that client's token, so the existing "release only my own fence" check can clear it.
  • No more racing: a restart registers itself with its host before its first remote step, not after it reaches the lock. A restart on a reconnected connection now always waits for this client's earlier restart on the dropped connection to finish. It never races it to the lock.
  • Unchanged: a fence with no token is still never claimed, and neither is one with another client's token. Only this process's own token releases a fence.

Why

Linked Issue

Fixes # (idle-exit e2e failure on #25815; follow-up to #25689)

Visual Proof

N/A. No UI change.

Testing

  • New wake test: the host creates the lock with the token, but the client sees the connection drop. The next restart clears that fence and starts the server. Against the phase3 restart code, this test fails with "fenced".

  • New wake test: a restart still taking the lock on a dropped connection is waited for, and the reconnected restart then starts the server.

  • New command test: the lock-creation command writes the owner token in the same command on POSIX and Windows. It writes nothing extra without an owner.

  • Existing tests: the other-client tests (no token, someone else's token) still return fenced.

  • Local: wake, activation, install-lock, retained-fence and remote-command suites pass (22 files, 260 tests). pnpm tc:node and the changed-code quality gate are clean.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Platforms. On Windows hosts the token goes into the same PowerShell lock script, next to the existing .owner file. Other install-lock callers pass no owner, and their commands are unchanged byte for byte.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…lock exists

The idle-exit e2e still read 'fenced' on reconnect: the launch-time wake's
lock landed on the host but its connection dropped before the client saw OK,
so the wake body never ran and never wrote its owner token, leaving a fence
nothing could prove. The token is now claimed before the lock and written by
the same command that creates it, and a wake registers itself before any
remote step so a reconnected wake waits for it instead of racing it.
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p3-wake-fence-atomic branch from 41b4e5f to 6a00ad6 Compare October 6, 2026 08:44
@OrcaWin

OrcaWin commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #25834, which carries this commit plus the follow-up wake-token fix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant