Added permanent failure support#59
Merged
Merged
Conversation
|
Coverage for this change: 13.3% |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the pgqueue task execution/locking behavior to better handle tasks that overrun their TTL and to prevent initialization-time insert failures by ensuring task partitions exist.
Changes:
- Updated
queue_lockSQL to (a) stop counting expired running tasks toward concurrency and (b) allow selecting expired running tasks for reclamation. - Ensured at least one task partition is created during
manager.Newbootstrap. - Added/expanded tests covering TTL/grace behavior and reclaiming expired running tasks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pgqueue/schema/objects.sql | Adjusts queue_lock logic to exclude expired running tasks from retained concurrency counts and allow reclaim selection. |
| pgqueue/manager/manager.go | Creates an initial task partition during manager bootstrap to avoid insert failures when no partitions exist. |
| pgqueue/manager/exec.go | Adds grace-period wrapper (runWithGrace) around callbacks to return on context deadline/cancellation. |
| pgqueue/manager/queue_test.go | Adds a regression test asserting queue progress continues when a running task expires. |
| pgqueue/manager/exec_test.go | Adds unit tests validating runWithGrace behavior when callbacks block or exit during grace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request introduces improvements to task queue management in the
pgqueuepackage, focusing on more robust handling of expired running tasks and ensuring partitions are available before task insertion. It also adds new tests to verify correct behavior when tasks exceed their TTL and when expired tasks are reclaimed, and updates the SQL schema to support these changes.Task execution and timeout handling:
runWithGraceandrunCallbackfunctions to allow task callbacks a configurable grace period to exit after context deadline, improving reliability when handling long-running or blocking tasks.Partition and queue management:
SQL schema updates:
objects.sqlto exclude expired running tasks from the retained set and to allow selection of new tasks when previous running tasks have expired, enabling proper task reclamation. [1] [2]