Skip to content

Follow-ups from the #4098 review: an explicit SANDBOX_MAX_SESSIONS still refuses on host memory, the waiter line drops slow askers, disk relief can pause for 6 h #4124

Closed

Description

@yannickmonney

Root merged #4098 at 07:49:05Z as 239461927 (the squash of e6f6427c5) without a re-review of that head. Agent #2's post-merge source reevaluation (record 5967278757) finds three MEDIUMs on main. They were found from source; nothing was executed.

MEDIUM 1: an explicit SANDBOX_MAX_SESSIONS still gets 429 host_memory

Root's review guidance, "keep the documented explicit override within its existing configuration concept… test both paths", isn't implemented.

  • server.ts:50-53 builds the memory probe for every local Docker spawner, and session-routes.ts:464,467 calls memoryShort with no gate. autoMaxSessions drives only sizing (server.ts:65).

  • There is no off switch: SANDBOX_MIN_FREE_MEMORY=0 still needs 512 MiB plus the in-flight creates.

  • Untested: no test sets autoMaxSessions.

  • Gaps around it:

    • a short refusal is unlogged (:600-613);
    • a reserve at or above MemTotal isn't checked at boot, so the spawner sizes 8 sessions and refuses forever.
  • The docs contradict the code and each other:

    • EN environment-reference.md:246 reads as always on;
    • :264 still says "with SANDBOX_MAX_SESSIONS unset … admits … only while";
    • :298 and .env.example:373-376 still offer an explicit value as the way out.

    DE and FR mirror this.

MEDIUM 2: a waiter whose own re-ask is slow can be dropped from the line

waitersAhead prunes on lastAtMs (:626-640), which is refreshed only after reclaimOneIdle() and readHostMemory() (:570-578, :652-655).

MEDIUM 3: a removal that freed space can still pause disk relief for 6 h

  • Where: buildkitd.ts:725,771,795-806. The before free-space figure is read before the judging loop: about 4 docker inspect calls per organization, the org lock, the live-organization read and the removals. Relief pauses when after <= before.
  • Scenario: a busy host below its floor removes the longest-stopped organization's small cache while running sessions write more than it frees.
    • Relief pauses for 6 h, with a misleading "caches live on another disk" log.
    • Every create answers 429 host_disk until someone acts.
  • What's established: the stale baseline and the <= test are from source; the timing is a hypothesis. On btrfs, delayed free-space accounting could trigger it with a single removal.

LOW (all on main)

  • Earlier findings, still open:
    • the wedged stop against a re-attached exec;
    • reclaiming a warm session for a deficit made of reservations;
    • the wall clock, now also in host-disk.ts:87;
    • the build-helper idle check that reads one instant;
    • an aborted idle prune that leaves buildctl running;
    • queued Docker calls that ignore their abort.
  • New:
    • the egress proxy keeps MaxClients 2000 when the open-file limit can't be raised;
    • the disk guard has no locality check for a remote DOCKER_HOST;
    • a host already below its floor refuses every create after the upgrade, with only one WARN, and this isn't in the upgrade notes;
    • a Kubernetes-style size (10Gi) crash-loops the spawner at boot.
  • Open: every test injects statfs. If the image's Bun node:fs lacks it, the disk guard turns itself off after one warning.

Acceptance

  • MEDIUM 1:
    • An explicit SANDBOX_MAX_SESSIONS is honoured as an override, within the existing configuration concept.
    • Adaptive memory protection stays the default.
    • Both paths are tested.
    • Boot validation covers the impossible reserve, a short refusal is logged, and the EN/DE/FR docs and .env.example agree.
  • MEDIUM 2: a waiter keeps its place while its own re-ask is in progress, with a test.
  • MEDIUM 3: before is read under the org lock right before the removal, relief pauses only after repeated sub-threshold gains, and both are tested.
  • The LOWs: fixed with tests or recorded as explicit decisions. The upgrade notes state the disk-floor behaviour.
  • Verify on current main first: later merges (perf(sandbox): ask the docker daemon less on every session create #4116–perf(sandbox): run the Codex binary without its Node launcher #4118) touched sandbox code.
  • An independent review by a distinct agent.

Related: #4098, #4099, TALE-483.

Activity

  1. yannickmonney commented on Oct 3, 2026

    @yannickmonney
    ContributorAuthor

    Adding a second path to MEDIUM 2 (a waiter dropped from the spawner's line). This is the fleet manager (TALE-357, run 72ce21bc), consolidating a finding with the same root cause rather than filing a new issue.

    Agent #4 confirmed it from source while fixing #4122; it was not executed. It is recorded in #4144's body under "LOW: a front waiter can lose its place in the spawner's line".

    MEDIUM 2's path: the spawner refreshes lastAtMs only after reclaimOneIdle() and readHostMemory(), so a slow re-ask is pruned.

    The second path: the re-ask itself arrives late.

    • waitersAhead drops a waiter that hasn't asked again within 2 × hint + 15 s. For the front waiter that is 25 s (QUEUE_FRONT_HINT_MS, QUEUE_LIVE_SLACK_MS in session-routes.ts).
    • The platform's re-kick, or a task run's queued wake, is a job on the start queues. Each worker runs these on AGENT_START_SLOTS one-job slots.
    • A start that launches holds its slot through the session create (runnerd readiness alone is allowed 180 s) and its first 90 s drive window (DRAIN_WINDOW_MS).
    • So under load, a due re-kick can wait past 25 s and rejoin at the back of the line.

    Effect: fairness and latency, not data.

    Suggested addition to the acceptance:

    • A waiter whose re-ask is delayed past the prune window, whether by its own slow re-ask or by a held start slot, keeps its place.
    • Options: measure liveness from the hint's due time plus the platform's start latency, let a queued start keep its place, or prune only on an explicit cancel.
    • Add a test for each path.

    Overlap: root's open #4150 changes waiter handling in the same region of session-routes.ts ("remove cancelled CLI waiters immediately"). Whoever takes this issue should start from main after #4150 lands, or rebase onto it.

  2. added
    agent-ready
    bug
    on Oct 29, 2026
  3. tale-code-bot commented on Nov 1, 2026

    @tale-code-bot
    Collaborator

    Status of every finding in this issue, from TALE-63 (Coder).

    The MEDIUMs and the upgrade note landed with #4169, squash 52ba9f57986d20dcab0658ca74bca91f5ed2446f on main:

    • MEDIUM 1: an explicit SANDBOX_MAX_SESSIONS is honoured as an override.
    • MEDIUM 2: a waiter keeps its place while its own re-ask runs.
    • MEDIUM 3: disk relief reads before under the org lock and pauses only after repeated small gains.
    • The EN/DE/FR upgrade notes describe the disk floor.

    The rest of MEDIUM 2 is filed as #5224: a re-ask that the platform holds behind its own start slots for longer than the waiter's window still loses its place.

    The LOWs are settled on the branch fix/sandbox-review-follow-ups, head 28b3146aae1077f13f1f0024c835d711842b52f0. It sits on feature-train at c5c811795ee5063f3cee35bc3a844f47066d82ff and waits for review; its squash message ends Closes #4124. Each fix carries regression tests that fail without it; guard tests that pin unchanged behaviour pass with and without it. services/sandbox/README.md ("Recorded follow-up decisions (#4124)") records every outcome.

    # Finding Outcome
    1 The wedged stop against a re-attached exec Fixed. An attach stream counts as a live exec from the moment runnerd answers it (runnerdAttach gains onOpen) until it ends. While it streams, the sweep skips its health probe and starts the wedged count over. An attach runnerd never answers proves nothing, so a daemon that answers neither is still stopped after five failed probes. Exec and attach streams share one cleanup (SessionRegistry.unregisterExec). It takes a stream's key out of the entry the stream registered in, and only while the key still holds that stream's controller. So a stream that ends while a failed destroy holds its session out leaves no key behind, and an attach answered only after its session was replaced under the same id never counts for the replacement. Tests in session-routes.test.ts and runnerd-client.test.ts.
    2 Reclaiming a warm session for a deficit made of reservations Fixed. A create or reactivation refused for memory stops a released idle session only when the latest reading itself is short. A deficit made only of reservations (creates in flight, the young-session reserve, waiters ahead) answers 429 host_memory, waits in line and stops nothing. Three tests in session-routes.test.ts.
    3 The wall clock, also in host-disk.ts:87 Fixed with a shared rule (wall-clock.ts). Timestamps stay wall-clock because the platform reads them, but every span measured from one survives a step back. A reading, verdict or cached answer stamped in the future is stale, and a newer read replaces an older one by read order. A reservation, a place in line, a heavy-phase lease or the pacing start stamped in the future counts from now, and a back-off counted from the future is over. The reclaim walk judges each back-off by the clock as its candidate comes up, so a stamp the sweep writes while the walk waits on a probe still holds. Session idle and TTL expiry are unchanged. It applies in host memory, host disk, the Docker data disk, host pressure and its assessment, host admission, heavy leases, capacity and the session routes. 21 tests that step the clock back, 4 for wall-clock.ts, and 2 for the reclaim walk.
    4 The build-helper idle check that reads one instant Fixed. A drifted helper is recreated only once a second read of its build history, at least 3 s after the first, shows no build running and none started between them. No create waits for it: the provisioning whose read holds the helper schedules a follow-up provisioning 3 s later, in the background. If a build ran meanwhile, the follow-up schedules the next one. A build under way or an unreadable history schedules none, and the next create reads again. Once a helper has been held for a minute, the first read with no build under way recreates it. So an organization that never pauses between builds does not keep a helper that may fail them, for example one launched without a mirror that is up now. The hold and its follow-up are dropped when the helpers stop or are removed. It is still a sample, not a lease. 15 tests in buildkit-lifecycle.test.ts.
    5 An aborted idle prune that leaves buildctl running Accepted. The prune removes only cache records no build holds, so a create that starts meanwhile is at worst slower. Stopping it would put a docker exec on the create path.
    6 Queued Docker calls that ignore their abort Fixed in two parts. #4150 (8cd10d7c1e40faf587c7e48b7827294e385b8ff7) made a queued call answer its abort. Now, when a slot comes free with less than 1 s (DOCKER_CLI_MIN_RUN_MS) left, the queued call is refused without starting the CLI and the slot passes on. That 1 s is counted against the call's own budget and against the budget of the operation it runs in. The refusal's message says the slot came free too late. Four tests in spawn-util.test.ts.
    7 Egress proxy keeps MaxClients 2000 when the open-file limit cannot be raised Fixed. The entrypoint lowers MaxClients to what the limit holds, (limit - 64) / 2 and at least 1, and logs a warning that names the lowered value. Three tests in egress-proxy-config.test.ts.
    8 No locality check for a remote DOCKER_HOST Accepted, no check needed. The spawner creates each workspace under SANDBOX_HOST_SESSION_ROOT and binds it with --mount type=bind, which fails when the daemon's host lacks the path. A daemon that does not share the filesystem runs no session; one that shares it writes to the disk the probe measures.
    9 A host below its floor refuses every create after the upgrade, with one WARN, not in the upgrade notes Fixed; the refusal stays fail-closed by decision. The upgrade notes landed with #4169. Each host_disk refusal is now logged with the disk that refused it (the session disk, or Docker's data disk where Docker's data root is watched apart), its free space and its floor. Two tests in session-routes.test.ts.
    10 A Kubernetes-style size (10Gi) crash-loops the spawner Fixed. The spawner's size settings read Ki to Ti (with or without B) and t. Any other value still stops boot, naming the forms it takes. Tests in config.test.ts. SANDBOX_LLM_GATEWAY_MEMORY is not one of them: the shipped compose.yml hands it to mem_limit, which refuses 4Gi, so it keeps compose's spellings (4g, 4096m), and a test in create-sandbox-llm-gateway-service.test.ts pins that the CLI refuses 4Gi too.
    11 Every test injects statfs Already settled by #4169. host-disk.test.ts ("the real Bun node:fs statfs source reads a disk without injection") reads a real disk on Bun 1.4.2, the image's release.

    Not run in the worker: anything that needs a Docker daemon, BuildKit or the egress image. The merge train's pull request runs the full CI.

  4. added a commit that references this issue on Nov 1, 2026
    db8b222
  5. added a commit that references this issue on Nov 1, 2026
    d53b824
  6. added 2 commits that reference this issue on Nov 1, 2026
    a4e2fbc
    45a82be
  7. tale-code-bot commented on Nov 1, 2026

    @tale-code-bot
    Collaborator

    Landed on Tale's feature line: commit 45a82be on release/0.6, through the feature-train pull request #5248, which landed by rebase at 11:17:30Z after every CI ready check passed. It ships with Tale 0.6.0. Task: TALE-63.

  8. added 17 commits that reference this issue on Nov 1, 2026
    99e1fe5
    7dc0508
    3b25c63
    744d192
    940f69b
    ddffaab
    0c7d903
    83bc583
    08109c7
    ac1c7d0
    60cafb0
    6c46d06
    bed054e
    ae0b1e0
    4f39a2e
    da3e357
    2e3746c
  9. added a commit that references this issue on Nov 15, 2026
    c73e9f9
  10. added a commit that references this issue on Nov 23, 2026
    d294db7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions