Skip to content

Page pending seed drains past the scan limit - #518

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-7252-pending_seed-listdue-never-advances-past-its-scan-limit
Aug 30, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-7252-pending_seed-listdue-never-advances-past-its-scan-limit

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

PendingSeedStore.listDue and both RowAccess list(limit) implementations took an unordered LIMIT n from the start of the table. drainOnce called that once per tick with PENDING_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 listDue over to a single ordered page API (no dual path):

  • Order by expiresAt ascending, then userId, tenantId.
  • Return { seeds, truncated, next? } with a keyset cursor.
  • drainOnce keeps that cursor across ticks so a full first page of never-expiring rows cannot starve everyone else.
  • DrainReport.truncated distinguishes "drained everything due" from "more work remains behind this tick's page".

The store still honors limit (peek limit + 1 to set truncated exactly). One drain tick still scans at most one page.

Test plan

  • bun test packages/onboarding — 175 pass, 0 fail
  • cd packages/onboarding && bun run typecheck

Linear: CL-7252

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.
@TheGreatAxios
TheGreatAxios merged commit 4faa5b9 into main Aug 30, 2026
5 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