Page pending seed drains past the scan limit - #518
Merged
TheGreatAxios merged 2 commits intoAug 30, 2026
Merged
TheGreatAxios merged 2 commits into
TheGreatAxios merged 2 commits into
Conversation
Outstanding rows past the scan limit currently starve behind an unordered LIMIT. These tests pin oldest-due order, keyset continuation, and DrainReport.truncated versus a complete drain.
listDue now returns an ordered page (expiresAt, userId, tenantId) with a keyset cursor instead of an unordered LIMIT from the start of the table. drainOnce keeps that cursor across ticks so a full first page of never-expiring rows cannot starve everyone else, and DrainReport.truncated says when more work remains.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PendingSeedStore.listDueand both RowAccesslist(limit)implementations took an unorderedLIMIT nfrom the start of the table.drainOncecalled that once per tick withPENDING_SEED_SCAN_LIMIT(50), so rows past the first page never got a pass — including when the first 50 never expire or never converge.This cuts
listDueover to a single ordered page API (no dual path):expiresAtascending, thenuserId,tenantId.{ seeds, truncated, next? }with a keyset cursor.drainOncekeeps that cursor across ticks so a full first page of never-expiring rows cannot starve everyone else.DrainReport.truncateddistinguishes "drained everything due" from "more work remains behind this tick's page".The store still honors
limit(peeklimit + 1to settruncatedexactly). One drain tick still scans at most one page.Test plan
bun test packages/onboarding— 175 pass, 0 failcd packages/onboarding && bun run typecheckLinear: CL-7252