Repository navigation
fix(sandbox): release resources safely under concurrent load - #4150
Merged
Merged
Conversation
Bound and fence session adoption across creates and drain transitions. Remove cancelled Docker CLI waiters immediately, close backpressured output consumers while executions remain attachable, and atomically fence idle/TTL cleanup by generation and activity time on capable runtimes. Add regression coverage, update the sandbox lifecycle contract and make the egress nofile-warning fixture independent of host limits. Preserve workspace data, resource ceilings and older-runtime compatibility.
yannickmonney
marked this pull request as ready for review
October 3, 2026 16:06
This was referenced Oct 3, 2026
Contributor
Author
|
Post-merge independent review of #4150 at Verdict: source accepted (INFO only). Interactions
INFO
Verified correct
Open: the disconnect detection relies on Bun's |
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
High concurrency exposed retained output consumers, cancelled Docker work that could still start, serial Kubernetes recovery, and stale cleanup decisions. Bound session adoption to eight endpoint reads, stop adopting when drain begins, remove cancelled CLI waiters immediately, and disconnect stalled exec/attach consumers while keeping their commands attachable. Idle/TTL cleanup now atomically checks the work generation and activity cutoff on capable runtimes before freezing compute; workspace preservation and older-image compatibility remain intact.
A Node 24 container stress comparison ran 16 concurrent executions in four identical read-only containers with 24 paused output readers. The fixed bundle released all paused readers, kept eight healthy streams, and completed all 16 reattachments; observed aggregate memory fell from 1,216 MiB to 875 MiB (~28% lower in this stalled-reader scenario). This is a resource/backpressure test, not a measurement of model throughput or maximum production agent capacity.
Checklist
bun run lint:sastpasses: 476 rules / 4,473 files / 0 findings; final adoption-source scan also clean.Test plan
idleReclaimretain the prior expiry checks until replaced.