Repository navigation
fix(api): a deployment whose runs keep failing is tried again, never left without a job (closes #486) - #508
Merged
Merged
Conversation
…left without a job (closes #486) A pipeline run that threw was left to pg-boss retries, which end after five; with no agent action left to wake it, the deployment kept its application's slot until someone cancelled it. The worker now queues a failed run again with a delay doubling from 15 s to 5 min, and at start and every 5 minutes queues again each deployment whose latest job failed for good. Signed-off-by: samuel mbabhazi <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
What changed
DeploymentWorker.handle(extracted from the queue callback): whenpipeline.runthrows, the worker no longer rethrows for pg-boss to retry. It queues the same deployment again, with a delay of 15 s that doubles up to 5 min, and counts consecutive failures in the job data (failures).waitresets the count, as before with the 15 s recheck.DeploymentWorker.sweep, run at start and then every 5 minutes: it wakes each deployment whose latestdeployment-runjob isfailed, up to 500, using one query on the jobs schema.Why
Closes #486. A run that threw was left to pg-boss's five retries. When they were exhausted, for example while the database timed out repeatedly before the first agent action, nothing would wake that deployment again. It kept its application's single active slot until someone cancelled it, even after the dependency recovered.
How it was tested
deployment-worker.spec.ts(new). All four cases failed first, becausehandleandsweepdid not exist.deployment-pipeline.integration.spec.ts, with real PostgreSQL and pg-boss 12:failed.sweep()adds onecreatedjob. A second sweep adds nothing.api:lintandapi:typecheck.Security considerations
The sweep reads only
organizationIdanddeploymentIdfrom the jobs schema, checks both as tenant ids, and each run reads its deployment in that organization's transaction, under row-level security. Nothing about the failure is stored.