Skip to content

A command that holds slots while it waits for memory blocks the queue, and the check does not show it #80

Closed

Description

@sourcehawk

Problem

The wrapper takes its slots first, and then it waits until the free memory holds its budget (reserve then wait_for_memory in bounded_run.py). While a command waits for memory, it holds its slots, but it has no scope yet. So --check shows no held line for it, and cpus-used does not count it.

On a machine where programs outside the queue use most of the memory, this blocks the queue with no visible cause. Seen on a 16-processor machine with 27 GiB of memory, 10 slots of 2 GiB:

  • --check printed free-slots=2, unused=0M, cpus-used=0, line=busy, and no held line. So 8 slots were taken, but nothing ran.
  • Seven wrappers waited for 7 to 32 minutes. All used 0% CPU, and none had started its command.
  • Five of them had no --memory, so each one used the default budget of about 7 GiB (4 slots). Two of them held 4 slots each. The default budget plus the headroom of 2.7 GiB needs about 9.9 GiB free. The machine had 9.2 to 9.5 GiB free, so they could not start.
  • The other waiters, also two with --memory 4G, could not get the slots that the two holders kept. A 4 GiB budget fits in the free memory.

This has two results:

  1. The user and the agent cannot see what holds the queue. The skill says that the held lines name what holds the queue, and here they named nothing. The user saw "a command waits for a long time, but no load and no CPU in use."
  2. A command whose memory cannot come free keeps its slots for as long as it waits. A smaller command that fits in the free memory waits behind it. The line lets the waiters take turns, but the turns do not help the waiters that already hold slots.

Steps to reproduce

  1. On Linux with the hard cap, start other programs until the free memory is a bit less than the default budget plus the headroom.
  2. Start two or more bounded commands with no --memory.
  3. Start a bounded command with a small --memory that fits in the free memory.
  4. Run the wrapper with --check.

Expected behaviour

--check shows each command that holds slots, also when it waits for memory and has not started. The command keeps its slots while it waits, so it keeps its turn. When no bounded command runs, a waiter exits 75 at once (#85), so the wait in the observed case cannot happen any more.

Acceptance criteria

  • --check prints a line for each wrapper that holds slots but has not started its command, with its budget, its slots, its age, its directory, and its command, and the line says that it waits for memory.
  • The skill tells the user how to read the new line: the command holds its slots and waits for the memory that a running bounded command frees, because programs outside the queue hold the rest.

Context

The free memory in the observed case was low because of programs outside the queue: IDEs, language servers, browsers, a container daemon, and several agent sessions. Swap was full (8 of 8 GiB).

Activity

  1. self-assigned this
    on Oct 2, 2026
  2. added
    bug
    on Oct 2, 2026
  3. sourcehawk commented on Oct 6, 2026

    @sourcehawk
    OwnerAuthor

    Decision: a command that waits for memory keeps its slots

    Before: the issue asked for two things. --check shows a command that holds slots while it waits for memory, and that command gives its slots back so that a smaller command can start (acceptance criterion 2).

    Now: only the first part ships. A command that waits for memory keeps its slots, and --check prints a waiting line for it with its budget, the slots it holds, its age, its directory, and its command. Criterion 2 is dropped. Commit: ce84ad9

    Why: the deadlock in the observed case was fixed by #85 (0.9.1). In that case no bounded command ran, so each waiter now prints no-memory and exits 75 at once, and frees its slots. A command now waits for memory only while another bounded command runs, and that wait ends when the running command frees its memory. If a waiter gave its slots back there, it would lose its turn: each time memory frees, a smaller command that fits could take it first, and a large command could wait with no end. Holding the slots is what keeps the line fair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions