perf(backfill): fast-lane Phase-1 via lifo + run scan despite deep backlog #133
Reference in New Issue
Block a user
Delete Branch "fix/backfill-lifo-fast-lane"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The hourly catalog-backfill scan had gone effectively dead on prod: its
job sat behind a ~430k-deep wait list and, even when it ran, self-skipped
because the queue backlog (431k) was far over the maxBacklog ceiling
(1000). Net result: newly-decoded / zero-parts vehicles were never
onboarded — they starved behind the deep-drill backlog (ic stuck at 28
for days, 0 backfill-scan jobs ever completed).
Root constraint (verified against bullmq 5.68 lua): moveToActive drains
the
waitlist (RPOPLPUSH from the tail) BEFORE theprioritizedZSET,so a
priorityjob is starved behind an already-deep wait queue — theopposite of what's wanted. The lever that works is
lifo: it RPUSHes tothe tail, where the very next RPOPLPUSH picks it, ahead of the FIFO
backlog. addJobFromScheduler honours lifo too, so the scan job itself can
jump the queue.
Changes:
fastflag through the init→children→parts chain; fast jobsare enqueued with
lifo:trueso the whole chain jumps the backlog.fast lane even when the backlog is over the ceiling; only Phase-2 (the
rolling rescan that piles on) is suspended while the queue is deep.
lifo:trueso it fires on the nexttick instead of being buried for days.
Tested: new prefetch-worker.service.spec (lifo wiring + Phase-1/Phase-2
gating), full api suite green (248 passed), typecheck + biome clean.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com