Repository navigation
fix(fleet-queue): list fetches in pages, --task verifies one task (#7871) - #8476
Conversation
) A single /list response reliably carries at most ~100 rows; above that the reply came back unusable and cmd_list rendered it as a silent (no tasks) with exit 0. Fetch any limit in 100-row pages over a broker-honored offset (PostgREST offset= and Turso OFFSET), refuse a rows-less reply loudly, and add list --task <id> (id filter on both backends) so a worker can verify a just-completed task directly. Task 14563.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73f11772f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| crate::client::list_offset_or_default(req.get("offset").and_then(|o| o.as_i64())); | ||
| let mut path = format!( | ||
| "tasks?select={select}&queue=eq.{}&order=priority.asc,created_at.asc&limit={limit}", | ||
| "tasks?select={select}&queue=eq.{}&order=priority.asc,created_at.asc&limit={limit}&offset={offset}", |
There was a problem hiding this comment.
Add a unique tie-breaker to the paginated list order
When multiple tasks share a priority and creation timestamp, this ordering does not uniquely order them. The new client fetches independent pages with different LIMIT/OFFSET values—for example, --limit 101 requests 100 rows followed by 1—so PostgreSQL can order tied tasks differently between requests, causing duplicate tasks and omitted tasks even without concurrent queue updates. Previously, fetching a single response did not introduce this cross-page inconsistency. Append id.asc to the PostgREST ordering and the equivalent ID tie-breaker to the Turso ordering.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the tie-breaker commit at the current PR head. Both paginated list orderings now end in a unique id tie-breaker: the PostgREST path orders priority.asc,created_at.asc,id.asc and the Turso path orders (priority IS NULL), priority ASC, created_at ASC, id ASC — so independent LIMIT/OFFSET page fetches cannot duplicate or omit rows that tie on priority and created_at. The remaining created_at-only orderings are single-row picks (LIMIT 1) and the separate creation-outbox list, which the paged fetch does not use. cargo test -p fleet-queue --all-features: 198 pass, 0 fail before the main merge; branch is on current main.
Fixes #7871 (task 14563).
Problem (reproduced live, 2026-11-11)
fleet queue list --status done --limit 101returns 101 rows;--limit 102,200and500print(no tasks)with exit 0.failed, 7 rows, at--limit 200); a status with many rows returns empty (cancelled, 361 rows, at--limit 200). The failure tracks the returned row count (~101 max per response), and the client rendered an unusable/empty reply as a silent(no tasks)— which reads as "task does not exist".Fix
client.rs):listnow fetches in pages ofLIST_PAGE_SIZE = 100(list_pages, a pure paging plan), advancing anoffsetuntil the requested limit is met or a short page ends the result. A/listreply whoserowsis missing or not an array is now a loud exit-3 error (list_rows) instead of a silent empty list. Newlist --task <id>filter verifies a single task's current status regardless of list size or ordering.queue_broker.rs):/listhonorsoffset(offset=param) andtask(id=eq.).turso_queue.rs):verb_listhonorsoffset(OFFSET) andtask(id = ?).list_offset_or_default: absent = 0, negative clamps to 0) at both broker trust boundaries.Tests (oracle-named)
list_pages_cover_the_limit_exactly— paging-plan oracle: pages are contiguous, ascending, each within the page size, and sum exactly to the requested limit; offset clamping cases.list_rows_rejects_a_reply_without_a_rows_array— the silent-empty oracle: Null / rows-less / non-array replies are errors; an explicit empty array is a legitimate empty list.cargo test -p fleet-queue --all-features— 198 passed, 0 failed on the laptop.Acceptance: a large
--limitnow returns rows page by page (never a silent empty), andfleet queue list --task <id>verifies a just-completed task'sstatus=donedirectly. Live verification against the production broker follows once this lands and the fleet binary is rebuilt/redeployed by the usual flip.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.