Skip to content

Leave the server that replaced a following one running - #7226

Merged
max-sixty merged 2 commits into
mainfrom
agent-a5320d95bc58a924c
Nov 26, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-a5320d95bc58a924c

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

After a Leaf update that moves the page protocol, a page server from the old copy asks the new copy to take it over (leaf server _follow), which renews the page and restarts its server. If another start, such as a checkout's leaf server start, had put its own server on the page in between, the renewal's restart stopped that replacement: on a page no live session held, the session server stayed down and the open tab lost its server; otherwise the server came back under the follow's Leaf instead of the one that started it. follow_copy checked which server was running only after the renewal.

follow_copy now passes the renewal a condition, that no server but the one that asked serves the page, and renew_layer and renew_held ask it with each reading they already take again under the page lock and transaction (still). A page no server serves still passes, since the renewal's own restart stops the asking server before its last reading. One window remains, between the locked reading and the restart's stop, the same one the follow's own restart already accepts after its last check; closing it would need the stop itself to compare server ids.

Codex found this while reviewing #7218, which moved follow_copy from hosting to vendoring; the bug predates the move.

Tests: test_a_stale_follow_leaves_the_server_that_took_its_place, which fails without the fix; test_server_lifetime, test_revendoring, and the renewal and follow cases of test_hooks and test_interact_layer; lint-imports and pre-commit.

This was written by Claude Code on behalf of max-sixty

After a Leaf update that moves the page protocol, a page server from the
old copy asks the new copy to take it over (`server _follow`). If another
start, such as a checkout's `leaf server start`, put its own server on the
page before the follow ran, the follow still renewed the page first. The
renewal's restart then stopped that replacement server. On a page no live
session held, a session server stayed down, so the user's open tab lost its
server until something started one again. Otherwise the server came back
under the follow's Leaf instead of the one that had started it. The follow
compared server ids only after the renewal, and the renewal's stop checks
only the claim, which both servers share.

`follow_copy` now passes the renewal a condition, `no_other_server`: no
server but the one that asked serves the page. `renew_layer` and
`renew_held` take it as `still`, so the renewal asks it with each of its
readings, the last two under the page lock before the restart and under
the transaction after it. A page no server serves still passes, since the
renewal's own restart stops the server that asked. What is left open is the
moment between the locked reading and the restart's stop, the same one the
follow's own restart leaves after its last check.

A test serves an unclaimed page at an older protocol under one server and
follows another; before this change the follow restarted the server in
place.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit 06c7985 into main Nov 26, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a5320d95bc58a924c branch November 26, 2026 05:04
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.

2 participants