Skip to content

Co-located execution workload can starve the bb server and leave threads spinning #1334

Closed as duplicate

Description

@amadad

Summary

On Linux, a co-located execution workload can exhaust the bb-app service cgroup and starve the bb server itself. The UI then shows an indefinite spinner because neither the server health endpoint nor the host daemon can respond.

The execution plane exhausting its budget should not make the control plane unavailable.

Environment

  • bb-app 0.36.1-nightly.31483791719.1
  • Ubuntu 24.04 / systemd / cgroup v2
  • 4 vCPU, 8 GiB RAM, 4 GiB swap
  • bb-app running as a user service
  • Service limits: MemoryHigh=3.5G, MemoryMax=4G, MemorySwapMax=512M

Workload

One visible parent thread with one child thread was active. That work expanded into:

  • the bb server and primary host daemon;
  • a Codex app-server and Pi bridge;
  • two concurrent TypeScript checks;
  • a persistent browser automation daemon with 16 Chromium renderers.

The browser daemon had reparented to the user systemd manager, but remained in bb.service's cgroup. Its subtree alone used approximately 1.83 GiB RSS.

Observed behavior

The shared cgroup reached approximately 3.8 GiB and stayed above MemoryHigh:

memory.current: ~3.8 GiB
memory.high:    3.5 GiB
memory.max:     4.0 GiB
memory.swap.current: 512 MiB
memory.events high: 2,677,099
memory.pressure some avg10=100.00
memory.pressure full avg10=98.70

The server, browser renderers, TypeScript processes, and a thread waiter entered uninterruptible sleep in:

mem_cgroup_handle_over_high

Both local endpoints timed out:

curl --max-time 5 http://127.0.0.1:38886/health  # timeout
curl --max-time 5 http://127.0.0.1:38887/        # timeout

The journal repeatedly reported server and host-daemon event-loop stalls, including multi-second delays. One thread timeline query took 199 seconds. Provider model requests and automation sweeps then timed out. The app continued to display a spinner without explaining that the execution host was resource-exhausted.

This is not the event-queue poisoning described in #1320; there were no repeated rejected daemon-event batches in this incident.

Why this appears structural

The packaged bb-app launcher starts the server and primary host daemon as managed child processes. Under an ordinary systemd deployment, the server, daemon, provider runtimes, and descendants launched by agent tools therefore share one service cgroup.

Runtime/session cleanup exists, but an agent command can intentionally or accidentally start a persistent or daemonized descendant. Resource exhaustion in that execution workload can consequently throttle the server that would need to report, stop, or recover it.

Removing MemoryHigh would change this from deterministic throttling into host-wide memory pressure or an OOM kill; it would not provide failure containment.

Expected behavior

  • Execution-host resource exhaustion must not make the bb control plane unavailable.
  • Affected turns should fail or pause with an actionable execution host resource exhausted state rather than spin indefinitely.
  • Operators should be able to run the server without co-located execution, or isolate the primary execution daemon from the server.

Suggested direction

Any one implementation may differ, but the product needs a containment boundary:

  1. Support a server-only mode that does not start a primary execution daemon.
  2. Run the primary host daemon/workloads in a separate service or resource domain from the server.
  3. Detect sustained host/cgroup pressure and reject or pause new turns before the control plane becomes unresponsive.
  4. Surface execution-host pressure and loss of daemon health in the UI.
  5. Consider configurable per-host/per-environment budgets and subprocess accounting, including daemonized descendants where the OS supports it.

The immediate local workaround is to use bb multi-machine support and dispatch work to a separate execution host, but failure containment should still be built into the app.

Activity

  1. amadad commented on Aug 11, 2026

    @amadad
    ContributorAuthor

    Additional diagnostic detail: this was not a host-wide OOM. memory.events recorded oom 0 and oom_kill 0, while the host still reported about 2.3 GiB available. The freeze was caused by sustained cgroup-v2 MemoryHigh reclaim throttling: bb tasks blocked in mem_cgroup_handle_over_high, including the server that needed to report and recover the workload. This distinction is important—the failure mode is a control-plane dead zone under execution-plane pressure, not merely an undersized machine being OOM-killed.

  2. amadad commented on Aug 12, 2026

    @amadad
    ContributorAuthor

    Additional production evidence from the same Atum deployment, now on bb-app 0.37.0:

    • Before upgrade, bb.service reached its 4 GiB MemoryMax and the kernel killed the BB server process inside the cgroup.
    • The service contained the server, host daemon, provider runtimes, and agent-launched descendants. At audit time, 17 Codex app servers used about 1.26 GiB RSS while only four BB threads were active.
    • Historical logs contained heartbeat/provider timeouts and event-loop stalls during pressure.

    A restart reduced current use, but that is recovery rather than containment. I support the issue's proposed invariant: execution-plane exhaustion must not make the control plane unavailable. A server-only mode or separate resource domain for the primary execution daemon would address the ownership boundary directly.

  3. added theissue type on Aug 12, 2026
  4. added
    host
    on Aug 18, 2026
  5. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1334.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): bb-app spawns server + primary host daemon (and every provider/agent descendant) as plain children in one cgroup, so cgroup-v2 memory.high reclaim throttling (mem_cgroup_handle_over_high) stalls the server along with the runaway workload; the only supported/documented deployment is that combined launcher (a split via the undocumented bb-server bin + bb-app host-daemon join works but is unadvertised, untested and heuristic for primary-host resolution), and since Harden host session liveness after sleep #421 host liveness ignores the heartbeat lease so a throttled daemon stays "connected" and threads stay "active" with no failure state or pressure signal.
    • Proposed fix: (1) Make the split deployment supported instead of accidental: expose the packaged bb-server bin as bb-app server in help/docs/CLI guide, have the installer optionally emit two systemd units (server with modest limits, daemon with the big MemoryHigh/MemoryMax, sharing the data dir so host-id-based primary-host resolution is deterministic), let bb-app host-daemon auto-enroll against a loopback server without the join dance, forward signals in the bb-server wrapper, and add a boot+enroll test; interim workaround today: bb-server.js in one unit + `bb-app --data-dir D host-daemon join --server…
    • Caveats: Repro used systemd-run --scope with MemoryHigh=800M on a 58 GiB host rather than a real bb.service unit; the throttled hog only reached ~512 MiB so pressure was milder than the reporter's — the UI showed a ~30 s loading skeleton rather than an infinite spinner, while /health, /api/v1/threads and the daemon port did hit 5 s curl timeouts and the server was seen in D state in __mem_cgroup_handle_ove…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  6. added
    confirmed-repro
    on Aug 18, 2026
  7. SawyerHood commented on Aug 25, 2026

    @SawyerHood
    Collaborator

    Duplicate of #2433

  8. added
    duplicate
    on Aug 25, 2026
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

    confirmed-reproduplicatehostperf

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions