Skip to content

A local endpoint's cleanup spares its successor by an ownership token, not dev/ino (card 005e1676) - #5544

Merged
joelteply merged 2 commits into
canaryfrom
005e1676/a-local-endpoint-s-cleanup-spares-its-su
Oct 27, 2026
Merged

joelteply merged 2 commits into
canaryfrom
005e1676/a-local-endpoint-s-cleanup-spares-its-su

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

local_stream::Owned::remove decided whether the endpoint was still its own by the
socket's (dev, ino). Linux reuses an inode number at once, so a predecessor's
cleanup removed its successor's socket:
a_live_owner_is_refused_and_an_old_cleanup_spares_its_successor failed at
mod.rs:134 on canary 107af91 and on every PR's host job (#5543 at cbba67a).

Now each bind writes a fresh ownership token (pid, clock, per-process count) to
the custody sidecar, under custody, and Owned keeps it. remove deletes the socket
only while the sidecar still holds that token, then clears it; a successor's bind
writes its own, so a late predecessor cleanup spares it whatever inode the socket
got. A crashed owner's leftover token is harmless: the next binder reclaims the
stale endpoint and writes its own. The custody wait stays bounded (2 ms poll,
2 s ceiling). The successor test no longer depends on inode reuse, so it is
deterministic on every OS: 60 of 60 stress runs pass on macOS; Linux is CI's.

Taken back from Fable: part a (#5533) is my code.

Co-Authored-By: Claude Opus 5.5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…, not dev/ino (card 005e1676)

local_stream::Owned::remove decided whether the endpoint was still its own by the
socket's (dev, ino). Linux reuses an inode number at once, so a predecessor's
cleanup removed its successor's socket:
a_live_owner_is_refused_and_an_old_cleanup_spares_its_successor failed at
mod.rs:134 on canary 107af91 and on every PR's host job (#5543 at cbba67a).

Now each bind writes a fresh ownership token (pid, clock, per-process count) to
the custody sidecar, under custody, and Owned keeps it. remove deletes the socket
only while the sidecar still holds that token, then clears it; a successor's bind
writes its own, so a late predecessor cleanup spares it whatever inode the socket
got. A crashed owner's leftover token is harmless: the next binder reclaims the
stale endpoint and writes its own. The custody wait stays bounded (2 ms poll,
2 s ceiling). The successor test no longer depends on inode reuse, so it is
deterministic on every OS: 60 of 60 stress runs pass on macOS; Linux is CI's.

Taken back from Fable: part a (#5533) is my code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…replacement is spared as well as a successor (Codex on #5544)

The token alone (ee9c615) let an old owner's cleanup remove whatever replaced its
socket outside custody: a regular file, a symlink, or a listener that never wrote
the sidecar. Owned now keeps the socket's (dev, ino) again beside the token, and
remove deletes the path only while it is still a socket with that identity AND the
sidecar holds this bind's token: the identity spares any replacement, the token a
successor whose socket reused the inode number.

Test: an_old_cleanup_never_removes_what_replaced_its_socket (a regular file and a
symlink at the path survive the old cleanup). Proven by mutation: with the
identity check removed it fails ("a regular file at the path survives").
The token's doc no longer claims absolute uniqueness; the stale Owned doc is fixed.
Host: 10 lib + 1 integration pass, 60/60 stress.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply merged commit 1157a4b into canary Oct 27, 2026
31 checks passed
@joelteply
joelteply deleted the 005e1676/a-local-endpoint-s-cleanup-spares-its-su branch October 27, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant