feat(jobs): queue retry and backoff policy per job type (closes #1128)#1874
Open
Dickson2015 wants to merge 1 commit into
Open
feat(jobs): queue retry and backoff policy per job type (closes #1128)#1874Dickson2015 wants to merge 1 commit into
Dickson2015 wants to merge 1 commit into
Conversation
…estOne#1128) - Add job-retry-policy.ts with configurable retry/backoff for all 17 JobTypes - Non-retryable error patterns (validation, bad addresses, invalid URLs) route directly to the dead-letter queue, bypassing remaining retries - Backoff strategies: exponential for I/O-bound jobs, fixed for maintenance - Attempt counts tuned by criticality: payouts=8, webhooks=7, email=6, analytics=3, maintenance=2, etc. - addJob() accepts optional jobType param; per-type policy merged into BullMQ options with precedence: caller > policy > DEFAULT_JOB_OPTIONS - DEFAULT_JOB_OPTIONS derived from DEFAULT_RETRY_POLICY (single source of truth) - job-scheduler.service.ts embeds __jobType in job data and applies policy for both scheduled and manually triggered jobs - Worker failed handler uses __jobType to look up policy and decide DLQ routing - Add unit tests: job-retry-policy.spec.ts (policy, backoff, non-retryable) - Add integration tests: jobs-retry-backoff.spec.ts (option merging, DLQ routing) - Add BackEnd/docs/QUEUE_RETRY_POLICY.md with full reference documentation Closes EarnQuestOne#1128
Contributor
|
Great job so far There’s just two blockers — the workflow is failing and merge conflict. Could you take a look and fix it so all checks pass? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements GitHub Issue #1128 — configurable retry and backoff policies per job type in the BullMQ queue layer.
Changes
BackEnd/src/modules/jobs/job-retry-policy.tsBackEnd/src/modules/jobs/jobs.constants.tsDEFAULT_JOB_OPTIONSderived fromDEFAULT_RETRY_POLICYBackEnd/src/modules/jobs/jobs.service.tsaddJob()accepts optionaljobType; worker routes non-retryable errors to DLQ immediatelyBackEnd/src/modules/jobs/services/job-scheduler.service.tsstartSchedule()andtriggerScheduleNow()embed__jobTypeand apply per-type policyBackEnd/test/jobs/job-retry-policy.spec.tsBackEnd/test/jobs/jobs-retry-backoff.spec.tsBackEnd/docs/QUEUE_RETRY_POLICY.mdBehaviour
JobTypeenum value has an explicitJobRetryPolicy(attempts, backoff type/delay, non-retryable error patterns, Redis retention limits).Invalid Stellar recipient address,Invalid email address,Invalid webhook URL) bypass all remaining retries and are immediately forwarded to the dead-letter queue.DEFAULT_JOB_OPTIONS.jobTypecontinue to useDEFAULT_RETRY_POLICY(5 attempts, exponential 5 s).addJob()call).Testing
Both new spec files pass. Failures in the run output are pre-existing in unrelated modules and were present before this PR.
Documentation
See
BackEnd/docs/QUEUE_RETRY_POLICY.mdfor per-job-type policy tables, backoff formulas, usage examples, and instructions for modifying a policy.Closes #1128