Public: anyone can read this; the crew can change it.

Sentinel: queue:check is past its budget: 5 checks wait for 2 slots, all busy; the oldest since 13:25; the longest running is #16599 at 5 min (limit 60). #16614

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/16605-sentinel-queue-check-is-past-its-budget → main 0 commits fork

  • Merged. mason/16605-sentinel-queue-check-is-past-its-budget was merged into main as 583a790.

Review

Sign in to review this change.
6 files changed +95 −22
docs/features/check-lane-full.md added +34
@@ -0,0 +1,34 @@
1 ---
2 topic: When something is wrong
3 row: A check lane with every slot busy asks to raise the check slots and files no issue
4 ---
5 # A check lane with every slot busy asks to raise the check slots and files no issue (#16605)
6
7 Vitals raise the check lane when a free check has waited longer than the
8 lane's budget (`BUDGETS.laneWait`, ten minutes). Vitals decide why from the
9 counts, never from the card's words (`src/kernel/vitals.ts`):
10
11 - **Every check slot busy:** the cause is `queue:check:full`. Once a check has
12 waited `STARVATION_MS`, the lane starts the longest-waiting check first
13 (`src/checks/pick.ts`). So a lane whose slots are all running is waiting for
14 slots, and only a person adds slots. The owner's needs show one card, for
15 example "5 checks wait for 2 slots, all busy; the oldest since 13:25; the
16 longest running is #16599 at 5 min (limit 60). Raise the check slots, or
17 leave them?" *Raise the check slots* means raising `checks.concurrency` on
18 `/settings/capacity`. More checks at once use more of the machine, and each
19 check runs slower beside another, so the forge never raises it by itself.
20 - **A slot free:** the cause stays `queue:check`. A lane that waits while a
21 slot is free is a scheduler defect. The sentinel still files it as a
22 builder's issue at once (`budgetBreaches` in `src/crew/sentinel.ts`).
23
24 **The sentinel rule.** `queue:check:full` is in `PERSON_ONLY`, beside
25 `queue:agent:full` (`docs/features/agent-queue-full.md`), so the sentinel never
26 files it. A builder cannot add slots, and #16605 showed why such an issue is no
27 use. Between 13:19 and 13:37 about thirteen pull checks of 5 to 14 minutes each
28 were queued for two slots. They started oldest first, as designed, and the
29 lane drained by itself. The pager still says when the cause holds and when it
30 clears (`src/crew/incidents.ts` owns every `queue:` cause). Each full stretch
31 stays its own row in `degraded_span` for the findings board.
32
33 A check that runs too long is a different cause. A lane held by a hung or
34 over-budget check raises `stuck:` or `budget:`, and those are still filed.
src/crew/sentinel.ts +4 −3
@@ -33,7 +33,7 @@ import { getUserByName, type User } from "../core/users.ts";
3333 import { migrate } from "../kernel/migrate.ts";
3434 import { createLog, recentErrors, redactSecrets, type ErrorLedger } from "../kernel/log.ts";
3535 import { spans } from "../kernel/degraded_history.ts";
36 import { QUEUE_AGENT_FULL, QUEUE_WAIT_MAX_MS } from "../kernel/vitals.ts";
36 import { QUEUE_AGENT_FULL, QUEUE_CHECK_FULL, QUEUE_WAIT_MAX_MS } from "../kernel/vitals.ts";
3737 import { STALE_AFTER_MS } from "../runs/lease.ts";
3838 import { isOutageSummary } from "./network.ts";
3939 import {
@@ -593,8 +593,9 @@ const BREACH_CAUSE = /^(queue:check|stuck:|budget:|red:|shared:)/;
593593 * Each stays a vitals card in the owner's needs, with its one action (`forgeRecommended`).
594594 */
595595 // An agent queue waiting with every slot busy waits for Speed, the owner's capacity and budget
596 // call (#16098): its spans stay on the findings board; minutes with a slot free are still filed.
597 export const PERSON_ONLY: readonly string[] = ["backup-refs:", "backup-repo:", QUEUE_AGENT_FULL];
596 // call (#16098), and a check lane with every check slot busy waits for the check slots (#16605):
597 // their spans stay on the findings board; minutes with a slot free are still filed.
598 export const PERSON_ONLY: readonly string[] = ["backup-refs:", "backup-repo:", QUEUE_AGENT_FULL, QUEUE_CHECK_FULL];
598599
599600 /**
600601 * A red main in another repository is its owner's to fix, not the forge's
src/kernel/vitals.ts +19 −15
@@ -106,10 +106,10 @@ export type NeedKind = "broken" | "todo";
106106 * One cause of the forge being off: the `needs` sentence, a `cause` key that
107107 * holds for as long as its condition does (`memory`, `disk`, `disk-floor`, `disk-80`, `disk-70`,
108108 * `db-size`, `db-growth`, `forges-memory`, `errors`, `internal`,
109 * `queue:<kind>`, `queue:agent:full`, `release`, `stuck:<runId>`, `red:<repoId>`,
110 * `shared:<repoId>:<test>`), when it began by the forge's own evidence (the oldest evidence the
111 * forge holds, else the first time this process saw it, held until the cause clears; `at` is never
112 * the answer to a repeat call), and where to look.
109 * `queue:<kind>`, `queue:agent:full`, `queue:check:full`, `release`, `stuck:<runId>`,
110 * `red:<repoId>`, `shared:<repoId>:<test>`), when it began by the forge's own evidence (the oldest
111 * evidence the forge holds, else the first time this process saw it, held until the cause clears;
112 * `at` is never the answer to a repeat call), and where to look.
113113 */
114114 export interface Degraded {
115115 readonly cause: string;
@@ -385,6 +385,16 @@ function queueSentence(
385385 */
386386 export const QUEUE_AGENT_FULL = "queue:agent:full";
387387
388 /**
389 * The cause of a long check lane when every check slot is busy (#16605): the
390 * lane starts the longest-waiting check first once it has waited
391 * `STARVATION_MS`, so a lane full of running checks is waiting for slots, which
392 * only a person adds (`checks.concurrency`, /settings/capacity). Set from the
393 * counts, as `QUEUE_AGENT_FULL` is. A lane waiting with a slot free stays
394 * `queue:check`: that is a scheduler defect, and the sentinel files it.
395 */
396 export const QUEUE_CHECK_FULL = "queue:check:full";
397
388398 /**
389399 * The lane's one sentence, with its cause: how many wait, since when, and
390400 * what runs. With one slot: "22 checks wait behind one lane; the oldest since
@@ -559,22 +569,16 @@ export function vitals(input: VitalsInput): Vitals {
559569 if (row.kind === "check") {
560570 // Checks a red main holds are not waiting for the lane: the red: card names them.
561571 // Age and "since" come from the free checks alone.
562 if (free.oldest !== null && now - new Date(free.oldest).getTime() > BUDGETS.laneWait)
572 if (free.oldest !== null && now - new Date(free.oldest).getTime() > BUDGETS.laneWait) {
573 const slots = Number(capacityValue(input.db, "checks.concurrency"));
563574 need(
564575 "todo",
565 "queue:check",
566 laneSentence(
567 free.n,
568 free.oldest,
569 checkRuns,
570 Number(capacityValue(input.db, "checks.concurrency")),
571 now,
572 Math.min(held, row.queued),
573 free.byAccount,
574 ),
576 checkRuns.length >= Math.max(1, slots) ? QUEUE_CHECK_FULL : "queue:check",
577 laneSentence(free.n, free.oldest, checkRuns, slots, now, Math.min(held, row.queued), free.byAccount),
575578 new Date(free.oldest).toISOString(),
576579 "/settings/capacity",
577580 );
581 }
578582 continue;
579583 }
580584 // Agent runs the dispatcher holds on purpose (a shut valve, the week's
test/account-held-lane.test.ts +22 −2
@@ -13,8 +13,9 @@ import { migrations } from "../src/core/schema.ts";
1313 import { openDb } from "../src/kernel/db.ts";
1414 import { createRun, type Run } from "../src/core/runs.ts";
1515 import { freeChecks } from "../src/checks/red_main.ts";
16 import { laneSentence, vitals } from "../src/kernel/vitals.ts";
16 import { QUEUE_CHECK_FULL, laneSentence, vitals } from "../src/kernel/vitals.ts";
1717 import { checkLimitSentence, setQuota } from "../src/settings/quotas.ts";
18 import { setCapacity } from "../src/core/capacity.ts";
1819 import { ErrorLedger, clearErrors } from "../src/kernel/log.ts";
1920 import { RefusedLedger } from "../src/kernel/internal_refused.ts";
2021
@@ -51,7 +52,7 @@ const lane = () =>
5152 signals: { errors: new ErrorLedger(), refused: new RefusedLedger() },
5253 dataDir: tmpdir(),
5354 disk: () => ({ freeBytes: 95, totalBytes: 100 }),
54 }).degraded.find((d) => d.cause === "queue:check");
55 }).degraded.find((d) => d.cause === "queue:check" || d.cause === QUEUE_CHECK_FULL);
5556
5657 describe("checks held by their own account's limit", () => {
5758 test("an account at its limit holds its queued checks; under it, or with no limit, none", () => {
@@ -96,6 +97,25 @@ describe("checks held by their own account's limit", () => {
9697 expect(Date.parse(found!.since!)).toBeGreaterThan(Date.now() - 16 * 60_000);
9798 });
9899
100 test("the lane's cause says whether it waits for slots or with one free (#16605)", () => {
101 setCapacity(db, "checks.concurrency", "2", "u1");
102 running("r1");
103 queued("r2", 15);
104 queued("r2", 12);
105 const cause = () =>
106 vitals({
107 db,
108 signals: { errors: new ErrorLedger(), refused: new RefusedLedger() },
109 dataDir: tmpdir(),
110 disk: () => ({ freeBytes: 95, totalBytes: 100 }),
111 }).degraded.find((d) => d.cause.startsWith("queue:check"))?.cause;
112 // A slot free while checks wait past the budget: a scheduler defect, still the builder's.
113 expect(cause()).toBe("queue:check");
114 // Every slot busy: the lane waits for the check slots, the owner's call.
115 running("r2");
116 expect(cause()).toBe(QUEUE_CHECK_FULL);
117 });
118
99119 test("laneSentence names the red main's hold and the account's, in that order", () => {
100120 const now = Date.parse("2026-01-01T02:00:00Z");
101121 expect(laneSentence(1, "2026-01-01T01:04:00Z", [], 4, now, 2, 3)).toBe(
test/sentinel.test.ts +13
@@ -758,6 +758,19 @@ describe("a budget breach is crew work at once", () => {
758758 }
759759 });
760760
761 test("a check lane waiting with every slot busy is the owner's capacity call, not a builder's issue (#16605)", () => {
762 const ins = bapp.db.query("INSERT INTO degraded_span (cause, sentence, href, opened_at, closed_at) VALUES (?1, ?2, '/settings/capacity', ?3, ?4)");
763 try {
764 // Open now, and held long enough in the day to be a degraded cause: neither path files it.
765 ins.run("queue:check:full", "5 checks wait for 2 slots, all busy; the oldest since 13:25; the longest running is #16599 at 5 min (limit 60).", NOW - 2 * 60_000, null);
766 ins.run("queue:check:full", "Any words at all.", NOW - 3 * 3_600_000, NOW - 3 * 3_600_000 + 40 * 60_000);
767 expect(budgetBreaches(bapp.db, NOW, brepo.id).some((f) => f.cause === "queue:check:full")).toBe(false);
768 expect(degradedCauses(bapp.db, NOW, brepo.id).some((f) => f.cause === "queue:check:full")).toBe(false);
769 } finally {
770 bapp.db.query("DELETE FROM degraded_span WHERE cause = 'queue:check:full'").run();
771 }
772 });
773
761774 test("a breach brings a hunt within a tick, inside the signal gap", () => {
762775 const t = Date.parse("2026-10-14T12:00:00.000Z");
763776 // No incident open: a stuck run beside an open queue incident is that incident's symptom
test/vitals.test.ts +3 −2
@@ -471,9 +471,10 @@ test("a lane older than its budget is degraded with its cause; a silent run is s
471471 const r = createRun(app.db, { repoId, kind: "check" });
472472 app.db.query("UPDATE run SET created_at=?2 WHERE id=?1").run(r.id, iso(now - (9 + i * 2) * 60_000));
473473 }
474 // The oldest has waited 13 minutes: past the lane's ten.
474 // The oldest has waited 13 minutes: past the lane's ten. Its one slot is busy, so the lane
475 // waits for slots: the owner's call (#16605).
475476 const v = vitals({ db: app.db, signals: app.signals, dataDir, disk: roomy, now });
476 const lane = v.degraded.find((d) => d.cause === "queue:check");
477 const lane = v.degraded.find((d) => d.cause === "queue:check:full");
477478 expect(lane?.sentence).toMatch(
478479 /^3 checks wait behind one lane; the oldest since \d\d:\d\d; the lane runs a check for 31 min \(limit 60\)\.$/,
479480 );

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs