mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(documents): keep document reads inside their job's expiry
Since the lab staging reads a long report in parts, one auto-index could make the transcription plus up to twenty reads of two calls each at the person's response timeout, hours past pg-boss's fifteen-minute default, which failed the job and retried it beside the reads still running. The staging now takes the run's deadline as a schedule and plans only the reads that fit before it. The index job is long, with an expiry above the calls that run before the plan can say no, a stop on jobDeadline and a lock per document; the document run hands the same staging its own deadline, which moves the run's expiry as the reads are planned. The document summary, one call and its reasoning repeat, gets an expiry above that worst case. ocrReadCallMs in the read core is the one per-call timeout both deadlines divide by. The expiry guard now names every importer of the document and lab read entry points with the queues that reach it. The runtime guard's planted cases stripped every file's comments again on each rescan, which took over a second alone and timed out under a full parallel run; the stripped text is now memoised. Refs #1274
This commit is contained in:
1 parent
96eeec6080
commit
a1ee2ac003
21 files changed
+434
-76
No files matched your search
@@ -60,9 +60,20 @@ const source = new Map(
|
||||
files.map((f) => [f, readFileSync(join(SRC, f), "utf8")]),
|
||||
);
|
||||
|
||||
/** Strip comments so documentation that quotes code never matches. */
|
||||
/**
|
||||
* Strip comments so documentation that quotes code never matches. Memoised
|
||||
* per text: the planted cases rescan the whole tree once per finding, and
|
||||
* stripping every file again each time made that one case take seconds,
|
||||
* past the default timeout under a full parallel run.
|
||||
*/
|
||||
const stripped = new Map<string, string>();
|
||||
function code(text: string): string {
|
||||
return stripComments(text);
|
||||
let out = stripped.get(text);
|
||||
if (out === undefined) {
|
||||
out = stripComments(text);
|
||||
stripped.set(text, out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Index just past the bracket that closes the one at `open`. */
|
||||
@@ -326,9 +337,7 @@ describe("every queue declares its runtime", () => {
|
||||
{ definitions: [planted({})], ...scan(texts(budgeted)) },
|
||||
),
|
||||
).toEqual(["planted-long: expiry 900s out of range"]);
|
||||
// Each finding rescans every send in the tree; under a full parallel run
|
||||
// that took six to nine seconds against the five-second default.
|
||||
}, 30_000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user