Skip to content

Djt/0617/dies at fix#58

Merged
djthorpe merged 4 commits into
mainfrom
djt/0617/dies_at_fix
Jun 17, 2026
Merged

Djt/0617/dies at fix#58
djthorpe merged 4 commits into
mainfrom
djt/0617/dies_at_fix

Conversation

@djthorpe

Copy link
Copy Markdown
Member

Fixed debugging messages

Copilot AI review requested due to automatic review settings June 17, 2026 11:24
@djthorpe djthorpe merged commit 0d2795d into main Jun 17, 2026
2 checks passed
@djthorpe djthorpe deleted the djt/0617/dies_at_fix branch June 17, 2026 11:24
@github-actions

Copy link
Copy Markdown

Coverage for this change: 12.4%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR changes how dies_at/task deadlines are represented and managed in pgqueue, shifting from “deadline set at insert time” to “deadline set when a worker locks the task”, and adjusts manager scheduling behavior accordingly.

Changes:

  • Make dies_at nullable in both the Go schema (*time.Time) and the SQL schema, and update logic to only treat tasks as expired when a deadline exists.
  • Move dies_at assignment to queue_lock (set on lock), and clear dies_at on queue_unlock/queue_fail.
  • Improve queue draining behavior in the manager run loop (cap per-round pickups and trigger immediate rescheduling when a slot frees up).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pgqueue/schema/task.go Changes Task.DiesAt to *time.Time to allow “unset until locked” semantics.
pgqueue/schema/objects.sql Makes dies_at nullable and moves deadline computation to lock/unlock/fail functions; updates expiration logic.
pgqueue/manager/task_test.go Updates task creation expectation to DiesAt == nil (deadline set on lock).
pgqueue/manager/run.go Caps queue pickup per round and resets queue polling when a task completes.
pgqueue/manager/exec.go Updates deadline handling to match nullable DiesAt.
pgqueue/manager/exec_test.go Updates tests for pointer-based DiesAt.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"initial_retries" INTEGER NOT NULL CHECK ("initial_retries" >= 0),
PRIMARY KEY ("id"),
FOREIGN KEY ("queue") REFERENCES ${"schema"}."queue" ("queue") ON DELETE CASCADE
) PARTITION BY RANGE (id);
"started_at" TIMESTAMPTZ,
"finished_at" TIMESTAMPTZ,
"dies_at" TIMESTAMPTZ NOT NULL,
"dies_at" TIMESTAMPTZ,
Comment thread pgqueue/manager/run.go
Comment on lines +180 to 182
// A slot just freed up — immediately try to pick up another task.
queueTimer.Reset(0)
continue
Comment thread pgqueue/manager/exec.go
Comment on lines 167 to +168
// Run the task function with the provided payload and deadline
child, cancel := context.WithDeadline(ctx, task.DiesAt.UTC())
child, cancel := context.WithDeadline(ctx, (*task.DiesAt).UTC())
Comment thread pgqueue/schema/task.go
Comment on lines 43 to 46
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
DiesAt time.Time `json:"dies_at,omitempty"`
DiesAt *time.Time `json:"dies_at,omitempty"`
Retries *uint64 `json:"retries,omitempty"`
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