commit 4aaa782c7a6155ac077d6b0cd5edb03ca5dc861a
parent 8e4fb917cfc40cc4d5e234339159b53c2849a782
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 23:34:53 -0500
storage: a drive reads slow only after two slow measurements in a row
Review nit: one long unit through onDrive (a big walk, a cold spin-up) put
the slow chip and banner up. noteDriveAnswer now counts consecutive
measurements at half the budget or more (slowStreak; a fast one resets it,
a stall clears it) and sights slow at SLOW_READINGS_IN_A_ROW (2). The
watchdog's "drive slow" refusal still marks slow at once. CHANGELOG and
FACTS name the rule and the hold's self-healing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/common/controller/storageWatch.test.ts b/common/controller/storageWatch.test.ts
@@ -720,6 +720,7 @@ test("a fake prober walks the drive ok -> slow -> stalled -> ok, and the gate fo
await seedRelocated(h, "on-cold", { targetExists: true });
const verdicts = [
{ answer: "ok" as const, detector: "stat" as const, latencyMs: 4 },
+ { answer: "ok" as const, detector: "stat" as const, latencyMs: 2_100 },
{ answer: "ok" as const, detector: "stat" as const, latencyMs: 2_200 },
{ answer: "stalled" as const, detector: "stat" as const, cause: "a stat of its root did not answer within 3 s" },
{ answer: "ok" as const, detector: "stat" as const, latencyMs: 6 },
@@ -736,6 +737,8 @@ test("a fake prober walks the drive ok -> slow -> stalled -> ok, and the gate fo
assert.equal(view().latencyMs, 4);
assert.equal(typeof view().lastOkAt, "number");
+ await pass(); // one slow reading: not yet slow
+ assert.equal(view().state, "ok");
await pass();
assert.equal(view().state, "slow");
assert.match(String(view().cause), /^a stat of its root took 2.2 s$/);
diff --git a/common/lib/storageHealth.test.ts b/common/lib/storageHealth.test.ts
@@ -713,8 +713,12 @@ test("the drive's four words: ok → slow → stalled → ok, from what the watc
assert.equal(ok.latencyFrom, "call");
assert.match(ok.text, /^answering — \d+ ms \(a read in the editor\), last at \d\d:\d\d$/);
- // A unit past half the budget: answered, and slow. Nothing refuses it.
- assert.equal(await onDrive(USB, () => new Promise((r) => setTimeout(() => r("late"), 130))), "late");
+ // A unit past half the budget: answered. One is not slow (a big unit, a
+ // spin-up); two in a row are. Nothing refuses either.
+ const lateUnit = () => onDrive(USB, () => new Promise((r) => setTimeout(() => r("late"), 130)));
+ assert.equal(await lateUnit(), "late");
+ assert.equal(driveHealthView(USB, locationHealth("usb")).state, "ok", "one slow reading is not slow");
+ assert.equal(await lateUnit(), "late");
const slow = driveHealthView(USB, locationHealth("usb"));
assert.equal(slow.state, "slow");
assert.match(String(slow.cause), /^a read in the editor took \d+ ms$/);
@@ -737,6 +741,8 @@ test("the drive's four words: ok → slow → stalled → ok, from what the watc
test("slow lasts two passes from its last sighting, then reads ok again", () => {
registerLocationHealth([USB], 0);
+ noteDriveAnswer("usb", 2_000, "stat", 9_000);
+ assert.equal(locationHealth("usb")?.slowAt, undefined, "one reading is not slow");
noteDriveAnswer("usb", 2_000, "stat", 10_000);
const h = locationHealth("usb");
assert.equal(h?.slowAt, 10_000);
@@ -782,3 +788,13 @@ test("the watchdog's slow refusal is a sighting of slow, and marks nothing", asy
assert.match(String(h?.slowCause), /did not answer within .*still completing others/);
assert.equal(driveHealthView(USB, h).state, "slow");
});
+
+test("a fast reading between two slow ones starts the count again", () => {
+ registerLocationHealth([USB], 0);
+ noteDriveAnswer("usb", 2_000, "call", 1);
+ noteDriveAnswer("usb", 3, "call", 2);
+ noteDriveAnswer("usb", 2_000, "call", 3);
+ assert.equal(locationHealth("usb")?.slowAt, undefined);
+ noteDriveAnswer("usb", 2_000, "call", 4);
+ assert.equal(locationHealth("usb")?.slowAt, 4);
+});
diff --git a/common/lib/storageHealth.ts b/common/lib/storageHealth.ts
@@ -114,12 +114,16 @@ export type LocationHealth = {
// its reads and writes took, over the requests that completed).
latencyMs?: number;
latencyFrom?: "call" | "stat" | "counters";
- // WHEN IT WAS LAST SEEN SLOW, and why: answering, but a measurement reached
+ // WHEN IT WAS LAST SEEN SLOW, and why: answering, but two measurements in a row reached
// `slowThresholdMs()` (half the budget), or the watchdog refused a call as
// slow (its disk still completing others). Slow is shown, never acted on:
// nothing refuses a slow drive that the budget does not.
slowAt?: number;
slowCause?: string;
+ // Consecutive measurements at or past `slowThresholdMs()`. Slow is sighted
+ // at SLOW_READINGS_IN_A_ROW (2): one long unit (a big walk, a cold spin-up)
+ // is not a slow drive.
+ slowStreak?: number;
};
// THE DEFAULTS, and why they are what they are (lib/storageHealthTimings.ts
@@ -340,6 +344,7 @@ function recordAnswer(
// afresh, and an old slow sighting is not what it is doing now.
delete prev.slowAt;
delete prev.slowCause;
+ delete prev.slowStreak;
return { id: loc.id, from, to: "stalled" };
}
if (prev.state === "stalled") {
@@ -501,8 +506,8 @@ const LATENCY_WORDS: Record<NonNullable<LocationHealth["latencyFrom"]>, string>
// THE DRIVE ANSWERED: a measurement of how long it took. Recorded for a
// location that has an entry (registered or answered); a path on no
-// configured location has none, and this does nothing for it. A measurement
-// at or past `slowThresholdMs()` is also a sighting of slow.
+// configured location has none, and this does nothing for it. The second
+// measurement in a row at or past `slowThresholdMs()` is a sighting of slow.
export function noteDriveAnswer(
id: string,
latencyMs: number,
@@ -517,11 +522,20 @@ export function noteDriveAnswer(
// other two are the drive answering.
if (from !== "counters") h.lastOkAt = now;
if (latencyMs >= slowThresholdMs()) {
- h.slowAt = now;
- h.slowCause = `${LATENCY_WORDS[from]} took ${latencyText(latencyMs)}`;
+ h.slowStreak = (h.slowStreak ?? 0) + 1;
+ if (h.slowStreak >= SLOW_READINGS_IN_A_ROW) {
+ h.slowAt = now;
+ h.slowCause = `${LATENCY_WORDS[from]} took ${latencyText(latencyMs)}`;
+ }
+ } else {
+ h.slowStreak = 0;
}
}
+// Two slow measurements in a row before a drive reads slow (review of lane
+// drive-stall): one long unit must not flash the banner.
+export const SLOW_READINGS_IN_A_ROW = 2;
+
// THE DRIVE IS SLOW, NOT STALLED: the watchdog refused a call past its budget
// while the disk was still completing others (`onDrive`, `acquireSlot`).
export function noteDriveSlow(id: string, cause: string, now: number = Date.now()): void {
diff --git a/common/views/storage.test.ts b/common/views/storage.test.ts
@@ -521,6 +521,7 @@ test("each location row carries its drive's health view; the internal row none",
const gone = loc("gone", "/mnt/gone");
registerLocationHealth([cold, warm, gone], NOW);
recordLocationHealth(cold, "stalled", { now: NOW, cause: "its disk (sdz) had 1 request(s) in flight and completed none in 15 s" });
+ noteDriveAnswer("warm", 2_400, "call", NOW - 1);
noteDriveAnswer("warm", 2_400, "call", NOW);
const probes = {
cold: { status: "stalled" as const, identity: { known: false as const }, probedAt: NOW },
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,8 +1,8 @@
# Changelog
## [Unreleased]
-- **The dashboard says when a media drive is not answering, slow, or not mounted.** A stalled external drive used to show only on `/storage` and in channel badges, so the editor looked broken with nothing on its front page saying why. The dashboard now opens with one card per storage location in trouble: **not answering** (an alert: pages and polls skip the drive, and its channels' jobs wait until it answers), **answering slowly** (everything still runs, just late), or **not mounted** (only when some channel's media is on it). Each card links to `/storage` and to that location's channels. On `/storage` each location has a **Drive** line that says when the drive last answered and how long it took (for example "answering — 12 ms (a read in the editor), last at 11:42"), and a **slow** chip appears next to Available when reads on it are taking half the 3-second limit or more. `pnpm ops get storage` reports the same for each location under `rows[].drive`: `state` (`ok`, `slow`, `stalled` or `unmounted`), `since`, `lastOkAt`, `latencyMs`, the cause and the one-line text.
-- **A transcription or backfill run waits while its channel's media drive is not answering.** Before, a run that started while the drive answered kept going after the drive stalled. Each next video asked the stalled drive for its audio, waited about 30 seconds and failed. Now the run pauses at the next video and says so in its log ("Holding: the media drive "…" is not answering (since 11:35) — no new transcription starts until it answers again"), then resumes by itself when the drive answers. A video that is refused because the drive is not answering is skipped, not added to the channel's failed-transcriptions list, and is transcribed on a later run. A downloaded video is also not moved into a saved-video store on a drive that is not answering. It stays in the video's folder, and a later pass stores it.
+- **The dashboard says when a media drive is not answering, slow, or not mounted.** A stalled external drive used to show only on `/storage` and in channel badges, so the editor looked broken with nothing on its front page saying why. The dashboard now opens with one card per storage location in trouble: **not answering** (an alert: pages and polls skip the drive, and its channels' jobs wait until it answers), **answering slowly** (everything still runs, just late), or **not mounted** (only when some channel's media is on it). Each card links to `/storage` and to that location's channels. On `/storage` each location has a **Drive** line that says when the drive last answered and how long it took (for example "answering — 12 ms (a read in the editor), last at 11:42"), and a **slow** chip appears next to Available when two reads in a row on it take half the 3-second limit or more (one long read is not enough). `pnpm ops get storage` reports the same for each location under `rows[].drive`: `state` (`ok`, `slow`, `stalled` or `unmounted`), `since`, `lastOkAt`, `latencyMs`, the cause and the one-line text.
+- **A transcription or backfill run waits while its channel's media drive is not answering.** Before, a run that started while the drive answered kept going after the drive stalled. Each next video asked the stalled drive for its audio, waited about 30 seconds and failed. Now the run pauses at the next video and says so in its log ("Holding: the media drive "…" is not answering (since 11:35) — no new transcription starts until it answers again"), then resumes by itself when the drive answers. If it has held for 5 minutes, the run checks the drive itself from a separate process, and it logs that it is still holding every 10 minutes. A run also follows a channel that is moved to another drive while it runs. A video that is refused because the drive is not answering is skipped, not added to the channel's failed-transcriptions list, and is transcribed on a later run. A downloaded video is also not moved into a saved-video store on a drive that is not answering. It stays in the video's folder, and a later pass stores it.
- **The drive watch no longer overwrites a tier you change while it is pausing channels.** The five-minute storage watch, which pauses the channels on a drive that went away and restores them when it comes back, could save its change in the middle of yours and undo it. It now waits for the same settings lock that the channel-priority save uses. The editor's `dev` script also gives Node 16 file-access threads, as `start`, the systemd unit and the container already do.
- **Deleting a channel takes it off every site.** On 9 Nov, deleting `mooler` left it in efapalyzer's `site.json`, and the site had to be fixed by hand. Danger → Delete and `pnpm ops delete-channel` now rewrite every site whose pool (`channels`) or cited scope (`citedChannels`) names the deleted channel, each as a `patchSite` under that site's lock, so a concurrent edit of the site is not written over (a rename already re-points them through the same writer). The ops answer names those sites in `sitesUpdated`. A site whose write is refused shows up as a `warnings` line, and the delete still stands. Sites that never named the channel are not written (`common/controller/siteMemberships.ts`).
- **`pnpm ops create-site` is the New site form, without a browser.** On 9 Nov an agent had to call `writeSite` from a tsx script to make `efapalyzer`. `create-site` takes `{"siteId", "siteTitle"}` and any of the form's fields: header title (default the title), description, tagline, wordmark lead, accent, public URL, Pages project, hub URL, audience, listed, publish policy, search, archives, duplicates, transcript downloads, PWA, archive cap, groups, default group, channels, cited channels, social links and related sites. It builds the FormData the form posts and saves it through the form's own action (`saveSiteAction` → `writeSite`), so you get the same validation and the same sentences. A new site is **private and unlisted** unless the body says `"audience": "public"` / `"listed": true`. An existing id is refused (409) unless `"update": true`, which is the site page's Save with only the given keys changed; every other key, and the published page list, is kept. Unknown channels, a channel's `groupId` that names none of the site's groups, unknown keys and keys of the wrong type are refused before anything is written. The existence check, the read of the stored site and the save are one read-modify-write under the site's lock (`withSiteLock`). The site form's own Save now takes the same lock, so neither it nor an update is written over a concurrent edit such as a Reports-tab pages patch. It answers the saved site.
diff --git a/plans/FACTS.md b/plans/FACTS.md
@@ -8155,7 +8155,7 @@ shipped". Anchors are at slice DT's tip (`r15/drive-timings`).
included; `counters`: the device's own average per completed request, Δ(fields 4 + 8 (+ 15 + 17)) /
Δcompleted between two samples — `blockStatTicksMs`, `countersLatencyMs` in `storageVolumes.ts`;
`parseBlockStat`'s shape is unchanged), and `slowAt`/`slowCause` (a measurement ≥
- `slowThresholdMs()` = budget / 2, or the watchdog's two "drive slow" refusals, `noteDriveSlow`). A
+ `slowThresholdMs()` = budget / 2 TWICE IN A ROW (`slowStreak`, `SLOW_READINGS_IN_A_ROW`; a fast one resets it), or either of the watchdog's "drive slow" refusals at once, `noteDriveSlow`). A
transition to stalled deletes slowAt. `noteDriveAnswer` writes only to an existing entry.
- **`driveHealthView(loc, health, { mounted })`** (`lib/storageHealth.ts`, pure) is the one view:
`stalled` (the record) > `unmounted` (record `absent`, or `mounted: false`) > `slow` (slowAt within
@@ -8170,7 +8170,12 @@ shipped". Anchors are at slice DT's tip (`r15/drive-timings`).
- **Batches hold mid-run.** `mediaStallHold(config, log, what)` (`lib/mediaStallHold.ts`, memory
only, edge-logged) is asked in the pool `limit()` of `runWhisperBatch` and of the backfill lane of
`runOperationBatch` (not digest): 0 while the channel's media location is stalled, so runPool
- pauses (its idle poll is unref'd — a unit test needs a keep-alive). It gates DISPATCH only: the
+ pauses (its idle poll is unref'd — a unit test needs a keep-alive). It heals itself: after `MEDIA_HOLD_REPROBE_AFTER_MS` (5 min) held, at most once per 5 min, a child
+ `stat` of the root (`probeLocationHealth`); answering clears a STALE record (no pass refreshed it for
+ 3 pass intervals) or counts once on a kept one. "Still holding" every 10 min; `reloadConfig` re-reads
+ the channel's targets at most every 10 s. Persist-videos and persist-kept ask
+ `savedVideosStoreRefusal` before each fetch and stop (`store-unavailable`, `skippedStoreUnavailable`);
+ `isMediaDriveHeld` is the one predicate (downloadOneManaged's inline whisper keeps the download's status). It gates DISPATCH only: the
batch's classification reads `data/` (readdir, the corpus disk) and never waits. The autoRunner
lanes were already held at pick time (`buildChannelWork`). `transcribeOneVideo` refuses before
`resolveAudioFile` with `MediaDriveHeldError` (`failureClass` "no-audio": skipped, never