Skip to content

feat: auto-cleanup DLQ entries when jobs succeed#7

Merged
ceejbot merged 1 commit intolatestfrom
fix/dlq-cleanup-on-job-success
Dec 19, 2025
Merged

feat: auto-cleanup DLQ entries when jobs succeed#7
ceejbot merged 1 commit intolatestfrom
fix/dlq-cleanup-on-job-success

Conversation

@rrogers-machinify
Copy link
Copy Markdown
Collaborator

Summary

When a job with a job_key completes successfully, automatically delete any DLQ entries with that same job_key. This prevents the DLQ requeue cron from repeatedly requeuing jobs that have already succeeded.

Problem

Previously, when a job was requeued from DLQ and then succeeded:

  1. The job completed and was removed from the main queue
  2. The DLQ entry remained with its requeued_count incremented
  3. On the next requeue cron run, it would be requeued again unnecessarily

Solution

  • Add delete_dlq_by_job_key() method to BackfillClient
  • Add DlqCleanupPlugin that implements LifecycleHooks
  • On on_job_complete, check if job has a job_key and delete matching DLQ entries
  • Auto-register the plugin when DLQ processor is enabled

Changes

  • src/client/dlq.rs: Add delete_dlq_by_job_key() method
  • src/dlq_cleanup_plugin.rs: New file with DlqCleanupPlugin
  • src/worker.rs: Auto-register cleanup plugin when DLQ is enabled
  • src/lib.rs: Export DlqCleanupPlugin

Test plan

  • Unit tests pass
  • Integration tests pass (except pre-existing flaky deadlock test)
  • Manual testing with real DLQ scenarios

🤖 Generated with Claude Code

@rrogers-machinify rrogers-machinify force-pushed the fix/dlq-cleanup-on-job-success branch from 9c1891f to 22882e0 Compare December 18, 2025 21:34
When a job with a job_key completes successfully, automatically delete
any DLQ entries with that same job_key. This prevents the DLQ requeue
cron from repeatedly requeuing jobs that have already succeeded.

Changes:
- Add `delete_dlq_by_job_key()` method to BackfillClient
- Add `DlqCleanupPlugin` that hooks into job completion
- Auto-register the plugin when DLQ processor is enabled

The cleanup is automatic and transparent - users don't need to change
anything. When DLQ is enabled, the cleanup plugin is automatically
added to the worker.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rrogers-machinify rrogers-machinify force-pushed the fix/dlq-cleanup-on-job-success branch from 22882e0 to 3ec8783 Compare December 18, 2025 21:38
Copy link
Copy Markdown
Owner

@ceejbot ceejbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heck YEAH the lifecycle hooks are working out nicely!

@ceejbot ceejbot merged commit 3da5548 into latest Dec 19, 2025
1 check passed
@ceejbot ceejbot deleted the fix/dlq-cleanup-on-job-success branch December 19, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants