Commit 64d518b
committed
fix(orb): index orb_relay_pending by created_at so the relay-drain prune stops full-scanning
pruneRelayPending runs on every pull-mode relay-drain (fleet-wide, every 30s) and filters
orb_relay_pending by a bare created_at predicate:
SELECT ... WHERE created_at < ? ORDER BY created_at, delivery_id LIMIT ?
DELETE WHERE created_at < ?
Both existing indexes (idx_orb_relay_pending_install, idx_orb_relay_pending_coalesce) lead with
installation_id, so neither serves a created_at-only predicate — the SELECT and DELETE full-scan
the table and can blow the pull request's AbortSignal.timeout(30_000) budget, surfacing as the
recurring TimeoutError in Sentry.
Add a (created_at, delivery_id) index: it turns both queries into range scans and lets the SELECT
satisfy its ORDER BY (created_at, delivery_id) straight from the index with no temp-B-tree sort.
Closes #74301 parent 25decd9 commit 64d518b
3 files changed
Lines changed: 49 additions & 0 deletions
File tree
- migrations
- src/db
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
879 | 879 | | |
880 | 880 | | |
881 | 881 | | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
882 | 886 | | |
883 | 887 | | |
884 | 888 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments