mirror of
https://github.com/supabase/supabase.git
synced 2026-06-28 03:19:09 -04:00
3d101e2415
Closes #47015 ## What kind of change does this PR introduce? Bug fix. ## What is the current behavior? The queue message list paginates with `WHERE enqueued_at > <last>` and `ORDER BY enqueued_at`. `enqueued_at` is not unique: pgmq defaults it to `now()`, so every message sent in one `send_batch` shares a timestamp. When a group of same-timestamp messages straddles a page boundary, the strict cursor skips the rest of that group, so those messages never appear in the grid even though they are still in the queue. With 40 messages from one batch, only 30 render. ## What is the new behavior? Pagination uses a composite `(enqueued_at, msg_id)` keyset cursor and orders by the same pair. `msg_id` is unique within each queue/archive table and breaks the tie, so no rows are dropped between pages. After the change, all 40 messages render. This mirrors the cron-runs query, which already paginates on a unique key. ## Additional context Added a test in `apps/studio/data/database-queues/database-queue-messages-infinite-query.test.ts` asserting next pages use the composite cursor and order by `enqueued_at, msg_id`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved database queue message pagination to reliably retrieve all messages, including those with identical enqueued timestamps, preventing potential message skipping during pagination. * **Tests** * Added test coverage for database queue message pagination behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Ali Waseem <waseema393@gmail.com>