Skip to content

fix(queue): persist permanently failed BullMQ jobs to dead letter queue#1898

Open
sureshsuriya wants to merge 1 commit into
gopaljilab:mainfrom
sureshsuriya:fix/issue-1897-bullmq-dlq
Open

fix(queue): persist permanently failed BullMQ jobs to dead letter queue#1898
sureshsuriya wants to merge 1 commit into
gopaljilab:mainfrom
sureshsuriya:fix/issue-1897-bullmq-dlq

Conversation

@sureshsuriya

Copy link
Copy Markdown

Description

This PR fixes Issue #1897 by introducing a durable Dead Letter Queue (DLQ) mechanism for BullMQ assessment jobs.

Previously, jobs that exhausted all retry attempts were only logged and retained temporarily in BullMQ's failed set before being automatically removed according to the configured removeOnFail policy. This made it difficult to inspect or recover permanently failed assessment jobs.

This implementation persists permanently failed jobs to a dedicated PostgreSQL table, allowing failures to be retained for debugging and future recovery while leaving the normal processing path unchanged.

Related Issue

Closes #1897

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • 🧪 Test addition or update

Changes Made

  • Added a new dead_letter_jobs table using Drizzle ORM to persist permanently failed jobs.

  • Added the corresponding database migration and updated Drizzle migration metadata.

  • Updated the BullMQ worker to persist jobs only after all retry attempts have been exhausted.

  • Preserved the existing retry behavior and successful job processing flow.

  • Added unit tests covering:

    • DLQ insertion after maximum retries are exhausted.
    • No DLQ insertion for transient failures before the retry limit.

Screenshots (if applicable)

N/A

Testing

  • I have tested these changes locally
  • I have added/updated tests where applicable
  • All existing tests pass

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code where necessary
  • I have updated the documentation if needed
  • My changes generate no new warnings or errors

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@sureshsuriya is attempting to deploy a commit to the gopaljilab's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the type:bug Something isn't working or throwing errors. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working or throwing errors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Permanently Failed BullMQ Jobs Expire Without a Durable Recovery Mechanism

1 participant