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

The checkouts sweep leaves a running check's own TMPDIR (<run>.tmp) alone: its tests' mkdtemp no longer fails ENOENT #17614

opened this From outside

Approved and green, ready to merge

number 2 in the queue: lands in about 15 min

grokbot/forge:fix/check-tmp-race → main 218 commits fork

Combined with main

The preview is built from combined/17614 (1ac520ea05): main merged into this pull's head. Merging lands that branch.

The checks line says which commit the check ran on.

What happens next

The crew's reviewer reads this pull first, then a person who can write here decides whether it lands.

Review

Sign in to review this change.
2 files changed +29 −4
src/checks/sweep.ts +4 −4
@@ -116,10 +116,10 @@ export async function sweepCheckouts(app: App, now: number = Date.now()): Promis
116116 if (STORES.has(name)) continue;
117117 // A gate has no run row: its checkout is spared until no gate could still be using it.
118118 if (name.startsWith("gate-") && gateMayBeRunning(join(root, name), now)) continue;
119 // `<id>.home` is the home of run `<id>`, `<id>.seeds` what its runner is seeded with
120 // (`runner_seeds.ts`) and `<id>.hands` what its runner handed back (`runner_hands.ts`): each
121 // lives and dies with it.
122 const id = name.replace(/\.(home|seeds|hands)$/, "");
119 // `<id>.home` is the home of run `<id>`, `<id>.tmp` its TMPDIR under the floor (`floor.ts`),
120 // `<id>.seeds` what its runner is seeded with (`runner_seeds.ts`) and `<id>.hands` what its
121 // runner handed back (`runner_hands.ts`): each lives and dies with it.
122 const id = name.replace(/\.(home|tmp|seeds|hands)$/, "");
123123 const gate = GATE_DIR.exec(id);
124124 if (gate !== null) {
125125 if (!gateHolding(app.db, gate[1]!, since)) await removeRunDir(join(root, name));
test/checks-home-sweep.test.ts +25
@@ -84,6 +84,31 @@ test("a finished run's home is removed, a live run's survives", async () => {
8484 expect(existsSync(home("no-such-run"))).toBe(false);
8585 });
8686
87 test("a live run's own temp directory (`<id>.tmp`, its TMPDIR under the floor) survives the sweep; a finished run's goes", async () => {
88 // The floor (#16856) gives a check `<id>.tmp` as TMPDIR. The sweep read it as run `<id>.tmp`,
89 // found no such run and removed it under the running check every 30 seconds: its tests' mkdtemp
90 // failed ENOENT, more often the longer the check ran (several at once).
91 const live = run();
92 claimRun(app.db, live.id);
93 const done = run();
94 claimRun(app.db, done.id);
95 finishRun(app.db, done.id, { state: "ok", summary: "ok" });
96 const tmp = (id: string): string => join(dataDir, "checks", `${id}.tmp`);
97 for (const id of [live.id, done.id]) mkdirSync(join(tmp(id), "forge-test-x"), { recursive: true });
98 await sweepCheckouts(app);
99 expect(existsSync(tmp(live.id))).toBe(true);
100 expect(existsSync(tmp(done.id))).toBe(false);
101 // A gate's temp directory is held by its open row, as its checkout and home are.
102 const oid = "d".repeat(40);
103 const open = beginGate(app.db, repoId, undefined, oid);
104 mkdirSync(tmp(gateRunId(oid)), { recursive: true });
105 await sweepCheckouts(app, Date.now() + GATE_DEADLINE_MS + 60_000);
106 expect(existsSync(tmp(gateRunId(oid)))).toBe(true);
107 endGate(app.db, open);
108 await sweepCheckouts(app, Date.now() + GATE_DEADLINE_MS + 60_000);
109 expect(existsSync(tmp(gateRunId(oid)))).toBe(false);
110 });
111
87112 test("the sweep leaves what the checks keep between runs: the map, the kept results, the test times, what a pull learned, the gates' logs (#12178)", async () => {
88113 // Every store sits under <data>/checks/ beside the checkouts. Swept as a stranger's checkout,
89114 // a map kept by main's verification was gone within 30 seconds and no check was ever seeded.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs