Skip to content

Jobs that lose the race at the agent-capacity acquire keep their worker, and waiting reviews time out #3889

Backlog

Description

@DanielLemoine

Problem

#3479 made a job defer when its agent is already at its per-agent ceiling at the pre-check. A job that passes the pre-check and then loses the race at the authoritative acquire still waits there by polling, holding its queue worker, unless it is a task import.

With PROPR_AGENT_RUN_ALIAS_LIMITS set, several jobs for the same alias submitted close together all pass checkJobAgentCapacity before any of them holds a slot. The ones over the ceiling then wait in prepareAdmittedAgent:

  • Only processTaskImportJob passes raceWaitMs: JOB_AGENT_CAPACITY_RACE_WAIT_MS, so only import jobs turn a lost race into a deferral. Issue jobs (processGitHubIssueJob.ts), pull request follow-ups (processPullRequestCommentJob.ts), reviews, goals and merge-conflict runs call it without raceWaitMs and keep polling.
  • The comment on JOB_AGENT_CAPACITY_RACE_WAIT_MS says only job types that have done nothing user-visible by then opt in, so this looks deliberate rather than an oversight. By the time an issue job reaches the acquire it has set the processing label, updated the task and created a worktree.
  • A review or scout waiting this way runs into its own 30-minute timeout (REVIEW_TIMEOUT_MS, SCOUT_TIMEOUT_MS) and ends with AgentCapacityWaitTimeoutError, which isAgentCapacityRefusal does not treat as deferrable. The review fails although nothing was wrong with it.
  • While a job waits at the acquire I could not find anything written to the task timeline, so the task looks active with no explanation. I read the code for this; I did not confirm it on a running instance.

The ceiling itself holds. On 4cc4f16 with real Redis and the Docker simulator, eight separate processes launching at once on an alias capped at 2 peaked at exactly 2 running, with 6 waiting and no leaked holders. This issue is only about what the waiting jobs do meanwhile.

Question

Should job types other than import give their worker back after a bounded wait at the acquire?

Options I can see:

  1. Opt the remaining job types into raceWaitMs and make the work they have already done safe to re-enter (label, task state, worktree).
  2. Leave them waiting, but record the wait on the task timeline the way the pre-check deferral does, and treat a review's or scout's capacity-wait timeout as a deferral instead of a failure.
  3. Reduce the race itself, for example by taking the slot at the pre-check rather than at container create.

Option 2 looks like the smallest change. I am raising this as a question because the current scoping reads as intentional.

Suggested acceptance

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions