Skip to content

fix(rollups): read the source order once per request - #1578

Merged
MBombeck merged 1 commit into
mainfrom
fix/source-priority-single-read
Nov 26, 2026
Merged

MBombeck merged 1 commit into
mainfrom
fix/source-priority-single-read

Conversation

@MBombeck

Copy link
Copy Markdown
Owner

The day readers memoised the source-priority read under their own key while every other reader called loadUserSourcePriority directly; Prisma batched whichever parallel reads landed in the same tick, so the digest sent the read in three to five statements and its budget flickered between 131 and 132 (main red on the Integration run of 8a6d407).

loadUserSourcePriority now shares one pending read per request (fresh in background events, unchanged outside an event); the day readers use it and day-source-priority.ts goes. A unit test fails if one request reads the row twice, parallel callers and the day reader included.

Budgets lowered to the measured counts (three identical local runs): summary 38 → 37, snapshot 88 → 86, digest 131 → 128, health status 59 → 51.

The day readers memoised the user's source-priority read under their own
key, while some sixty other readers called loadUserSourcePriority
directly. A digest request reached it from both sides; parallel direct
reads went to Prisma, which batched whichever landed in the same tick,
so the route sent the read in three to five statements and its count
followed the scheduling.

loadUserSourcePriority now shares one pending read per request under
one key (fresh in a background event, as before), and the day readers
use it. The budgets of the summary, snapshot, digest and health status
drop to the counts measured on the fixture.
@MBombeck
MBombeck merged commit ca60dc9 into main Nov 26, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant