Skip to content

gate-lease: waiters race for the lease instead of queuing in order, so an old waiter can time out behind newer ones #2473

Closed

Description

@cliffhall

Problem

scripts/gate-lease.mjs (#2339) serializes concurrent npm run local:gate runs, but the waiters are not ordered. Every waiter polls proper-lockfile.lock() every POLL_MS (2s), and whichever poll lands first after a release wins. A gate that has been queued longest has no advantage over one that arrived a second ago.

With a deep queue that matters, because MAX_WAIT_MS (45 min) is a total budget from the first attempt. Observed on 2026-09-23: six gates queued at once across worktrees (-2405, -2407, -2412, -2422, -2458, inspector-2403). The holder had itself waited ~15 min, and the oldest waiter had been queued 17 min. At ~6 min a gate, an old waiter can lose several races in a row to newer arrivals and time out with a "gave up" failure that has nothing to do with its diff, while a gate queued after it runs.

Expected

Waiters take the lease in the order they started waiting. The Nth gate in line waits for the N−1 ahead of it and no longer. A waiter's progress line can then also say where it is in line.

Constraints

  • Keep what Nothing coordinates concurrent local:gate runs across worktrees #2339 already guarantees: a crashed holder releases within STALE_MS, an unwritable lease dir degrades to running unleased, signals stop the whole tree, and INSPECTOR_SKIP_GATE_LEASE bypasses the lease.
  • A waiter that dies (killed terminal, Ctrl-C while queued) must not block the queue behind it for long.
  • Update the lease section of docs/quality-gate.md and the AGENTS.md pre-push-gate bullet to match.

Activity

  1. added this to the v2.9.0 milestone on Sep 24, 2026
  2. self-assigned this
    on Sep 24, 2026
  3. added
    v2
    chore
    on Sep 24, 2026
  4. cliffhall commented on Sep 24, 2026

    @cliffhall
    MemberAuthor

    Triage: Priority Medium (total 8)

    • Severity 3 — a queued gate can fail with a spurious "gave up" timeout; re-running is the (annoying) workaround
    • Urgency 3 — wanted this milestone; six concurrent gates were queued when it was observed
    • Bonuses: +1 milestone (filed through the create flow), +1 assigned

    Board: #28, Status In Progress.

  5. cliffhall commented on Sep 24, 2026

    @cliffhall
    MemberAuthor

    Shipped in #2476.

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

Metadata

Metadata

Assignees

Labels

chorev2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions