Repository navigation
Conversation
The managed serve is spawned detached, which frees it from the client's lifetime but not its cgroup. A client under memory or pids limits still starves the shared server until the health probe fails and it gets recycled into another constrained client cgroup. On Linux, spawn through systemd-run --user --scope when a user session bus is available so the serve lands in its own transient scope, a sibling of the client's cgroup, and --collect removes the scope when it exits. Other platforms keep the direct spawn. Fixes anomalyco#48588
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
A stale or forwarded user-bus socket can pass the spawn gate while the user manager rejects the scope; detached hides the systemd-run exit, so wait out the registration budget and retry with the direct spawn. Also treat an empty XDG_RUNTIME_DIR as absent so the bus probe never resolves relative to the caller's cwd.
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
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.
Summary
Fixes #48588.
Daemon.start()spawns the managedservewithdetached: true. That detaches the session but leaves the process inside the spawning client's cgroup. A client running under memory/pids limits (asystemd-runscope, container, etc.) then starves the shared server until the 2s health probe fails and it is recycled into another client's constrained cgroup — the kill/respawn loop described in the issue.systemd-runare available, the serve is now spawned throughsystemd-run --user --scope --quiet --collect, so it lands in its own transient scope — a sibling of the client's cgroup — and--collectremoves the scope when the serve exits.detachedhides the exit). In that case the registration never appears, so after the existing ~5s retry budget we fall back to the direct spawn.Test plan
bun typecheckinpackages/cli— cleanoxlint— no new findingsprettier --check— cleanservice startfrom a scope-confined client put the serve inapp.slice/run-p<pid>.scope(a sibling of the client's scope),service statushealthy,service stopSIGTERMed it and the scope was collectedXDG_RUNTIME_DIRat a dir with a stalebusfile —systemd-runfailed, the registration retry elapsed, the direct spawn ran, and the server registered and stopped cleanlyprocess.platform,XDG_RUNTIME_DIR, bus socket, andsystemd-runpresence)Not included here (possible follow-ups from the issue): tolerating reclaim stalls in the health probe, and ownership semantics for which client may recycle the registered server.