Repository navigation
fix(daemon): reclaim serial sessions whose clients have all exited (#1429) - #1727
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 43 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…1429) A session is published by open_port before its client attaches a reader. If that client dies in between (or the WS attach times out), the session is left with an owner but no readers/writer, no idle close is scheduled, and the port returns EBUSY to every other opener until something else closes it. fbuild daemon locks already showed the owner as (dead). Every 2s the daemon now closes sessions in which every known client has a recorded pid and none of those processes is alive. Sessions with a live or unknown-pid client are kept, so the deploy -> attach hand-off is untouched.
zackees
force-pushed
the
fix/1429-reclaim-dead-client-port
branch
from
October 25, 2026 04:41
78b4906 to
2abf5e8
Compare
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.
Refs #1429. This is the issue's "request 1": reclaim a port lock when its owning client is gone.
Mechanism
SharedSerialManager::open_portpublishes the session (OS fd open,owner_client_idset) before the client attaches a reader or writer. The only automatic close isclose_port_after_grace_if_idle, which runs on reader/writer detach. So when a client dies afteropen_portbut before attaching, or the WS attach times out, the session is left like this:That is exactly the
fbuild daemon locksoutput in the issue. Nothing schedules a close for it, so every other opener gets EBUSY. A later generation bump can also cancel a pending grace close without rescheduling it.Change
handlers::locks::reclaim_dead_client_serial_sessionscloses a session only when every client it references (owner, writer, readers and the metadata entries) has a recorded pid and none of those processes is alive.DEAD_CLIENT_SERIAL_RECLAIM_INTERVAL).clear-locks --stale: a session with no readers or writer but a live or unknown-pid owner is kept, because that is the normal deploy → attach hand-off.Verification
soldr cargo test -p fbuild-daemon(288 + 13 pass). Workspace clippy with-D warningsis clean.fbuild monitorheld the port, thenkill -9on the CLI, and the port was released 2.2 s later. That release came from the existing WS-disconnect path, not this sweep, which confirms the normal path is unchanged. I could not reproduce the open-then-die-before-attach window without the reporter's two-device rig, so the new path is covered by unit tests only.Not covered
The issue's "request 2" (timeout message naming the dead client) is not in this PR;
open_port_timeout_messagealready names the holding process.