Skip to content

Improve PostgreSQL Queue Driver#300

Merged
rkeene merged 5 commits into
mainfrom
bug/improve-concurrency-for-postgres-queue-driver
May 10, 2026
Merged

Improve PostgreSQL Queue Driver#300
rkeene merged 5 commits into
mainfrom
bug/improve-concurrency-for-postgres-queue-driver

Conversation

@rkeene
Copy link
Copy Markdown
Member

@rkeene rkeene commented May 9, 2026

This change updates the PostgreSQL queue driver to not require the serializable isolation level by performing an atomic update-and-check when adding instead of splitting that into multiple queries would could cause insert conflicts when competing adds were performed concurrently. This should greatly improve the performance of the driver since there will be far fewer serialization errors.

@rkeene rkeene requested a review from Copilot May 9, 2026 22:34
@rkeene rkeene self-assigned this May 9, 2026
@rkeene rkeene added bug Something isn't working queue labels May 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the PostgreSQL-backed queue storage driver to reduce contention and serialization failures during concurrent add() operations by making inserts idempotent at the database level and running transactions at a less strict isolation level.

Changes:

  • Switches queue operation transactions from SERIALIZABLE to READ COMMITTED.
  • Refactors add() to use INSERT ... ON CONFLICT DO NOTHING ... RETURNING for atomic existence checks and bulk idempotent-key insertion via unnest(...).
  • Slightly restructures retry handling to more explicitly detect retryable PostgreSQL error codes (serialization/deadlock).

Comment thread src/lib/queue/drivers/queue_postgres.ts Outdated
Comment thread src/lib/queue/drivers/queue_postgres.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/lib/queue/drivers/queue_postgres.ts Outdated
Comment thread src/lib/queue/drivers/queue_postgres.ts
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/lib/queue/drivers/queue_postgres.ts
@rkeene rkeene marked this pull request as ready for review May 10, 2026 01:44
@rkeene rkeene merged commit 6df0989 into main May 10, 2026
6 checks passed
@rkeene rkeene deleted the bug/improve-concurrency-for-postgres-queue-driver branch May 10, 2026 02:43
@ezraripps ezraripps added this to the v0.0.62 milestone May 11, 2026
@ezraripps ezraripps mentioned this pull request May 11, 2026
ezraripps added a commit that referenced this pull request May 11, 2026
Includes changes from
 - #294 
 - #301 
 - #293 
 - #291 
 - #300 
 - #297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants