Skip to content

feat(worker): move coexist media backfill jobs to a dedicated low-priority queue - #1253

Merged
viethung0o0 merged 1 commit into
mainfrom
feat/low-priority-queue
Sep 20, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
feat/low-priority-queue

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

What

Move coexistAttachmentDownload and updateContactAvatar off the latency-sensitive integration queue onto a new workload-class low queue + worker, so a historical-import burst no longer starves the customer-reply path.

Changes

  • New low queue (queueNames + queues/low) and worker src/low/worker.ts (wrapped in withBlockedOwnerGuard), tunable via LOW_WORKER_CONCURRENCY (default 30).
  • Extract a shared, channel-agnostic enqueueAttachmentDownloadJobs helper; each caller keeps its original error policy (WhatsApp/Messenger best-effort, Instagram propagates).
  • Coexist / Customer-Scan enqueues now target the low queue.

Two-phase cutover (safety)

Release 1 (this PR): producers enqueue to low, but the integration worker still handles the two actions so in-flight jobs already queued are not dropped. Release 2 (later, once the integration queue is drained) removes the old cases.

Deploy note

Deploy the batch stack so a worker low consumer is running, otherwise the jobs queue in low unprocessed.

Test plan

  • pnpm --filter worker check-types, pnpm --filter @chatbotx.io/worker-config check-types
  • pnpm --filter worker test (242 files, 2644 tests)
  • pnpm --filter worker build emits dist/low/worker.mjs
  • New tests: low worker routing + blocked-owner guard, attachment + avatar enqueue helpers

…ority queue

Move coexistAttachmentDownload and updateContactAvatar off the latency-sensitive
integration queue onto a new workload-class `low` queue + worker, so a historical
import burst no longer starves the customer-reply path.

- add the `low` queue (queueNames + queues/low) and LOW_WORKER_CONCURRENCY (default 30)
- new src/low/worker.ts consumer wrapped in withBlockedOwnerGuard, high concurrency
- extract a shared, channel-agnostic enqueueAttachmentDownloadJobs helper (DRY);
  each caller keeps its original error policy (WhatsApp/Messenger best-effort,
  Instagram propagates so the run re-drives before the watermark advances)
- point coexist / customer-scan enqueues at the low queue; the integration worker
  keeps the old cases for a two-phase cutover so in-flight jobs are not dropped
- tests: low worker routing + blocked-owner guard, attachment + avatar enqueue helpers
@github-actions github-actions Bot added the feature New feature or request label Sep 20, 2026
@viethung0o0
viethung0o0 merged commit 39503e5 into main Sep 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants