Skip to content

feat(platform): reserve memory for the database and platform so sandbox sessions cannot starve them #4726

Closed

Description

@yannickmonney

Summary

Sandbox sessions start with --oom-score-adj=500 (services/sandbox/src/session/docker-session-args.ts:558), so a host-wide OOM kill picks them before the control plane. Nothing protects the control plane's memory before that point: the CLI's generated stack sets hard mem_limits on backend, sandbox, egress and gateway only (tools/cli/src/lib/compose/services/create-*-service.ts), nothing for db or platform, and no mem_reservation anywhere; the repo's compose.yml has its resource blocks commented out (compose.yml:121-129,320-328). Verified on main at 73d03a9.

Under memory pressure from sessions, the kernel reclaims the database's and the platform's pages as readily as anyone's. That is how a busy host turns into pool timeouts and 503s (the incident in #3977). The spawner's admission reserve (SANDBOX_MIN_FREE_MEMORY, default a tenth of the host and at least 1 GiB, services/sandbox/src/host-memory.ts:59-67) is a reading, not a guarantee.

Suggested fix

Set mem_reservation (cgroup v2 memory.low) on db, platform and backend in the CLI's compose generators and in compose.yml, sized from the deployment defaults; optionally a negative oom_score_adj for db. Default SANDBOX_MIN_FREE_MEMORY to at least their sum so admission and reclaim agree, and document both in the self-hosting docs.

Activity

  1. added
    priority: low
    improvement
    service: platform
    on Oct 10, 2026
  2. added
    agent-ready
    on Oct 29, 2026
  3. added
    feat
    and removed
    improvement
    on Nov 1, 2026
  4. added a commit that references this issue on Nov 2, 2026
    2ea9608
  5. added 3 commits that reference this issue on Nov 2, 2026
    24a091d
    db25699
    0913747
  6. tale-code-bot commented on Nov 2, 2026

    @tale-code-bot
    Collaborator

    Landed on release/0.6, the 0.6 feature line, with feature train #5329 as 0913747 (feat(cli): reserve memory for the database and the application tier); it ships with Tale 0.6.0. GitHub closes issues only for commits on main, so the feature-train role closes this one. Board task: TALE-135.

  7. added 12 commits that reference this issue on Nov 3, 2026
    0dd813d
    c2c16a0
    ca3eb66
    aadcf2a
    e0a44a3
    52d2013
    dcadac9
    be5b7a2
    4f2df9b
    be796ff
    18361fa
    6baf556
  8. added a commit that references this issue on Nov 15, 2026
    69425c4
  9. added a commit that references this issue on Nov 23, 2026
    e842708
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-readyfeatpriority: lowservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions