You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(db-vercel-postgres): reuse transactions for document lock checks (v3) - #19594
Backports #19589 to 3.x, on top of the merged Postgres lock fix in #19552. Vercel Postgres uses the same Drizzle transaction machinery and can exhaust its pool when a save holds a transaction connection while its document-lock read requests another connection.
Changes
Move the isolation-aware findDocumentLocks implementation into @payloadcms/drizzle/postgres and register it in both Postgres adapters.
Reuse the active transaction under Read Committed/Read Uncommitted, retaining independent lock reads under Repeatable Read/Serializable so newer locks remain visible.
Test Plan
pnpm run test:int:postgres test/locked-documents/int.spec.ts: 19 tests passed on 3.x.
pnpm exec tsc -b packages/db-postgres packages/db-vercel-postgres --pretty false: passed with the v3 lockfile dependencies installed.
ESLint and Prettier checks passed for all changed source files; git diff --check passed.
Dedicated Vercel Postgres test coverage and CI integration remain deferred to a separate follow-up, matching #19589. Hosted Vercel/WebSocket transport was not exercised.
No actionable comments were generated in the recent review.
Walkthrough
The Postgres Drizzle package now exports findDocumentLocks. The Postgres and Vercel Postgres adapters import the function from that package. Its receiver type and internal imports now reference package-local modules.
Changes: Postgres lock finder
Layer / File(s)
Summary
Lock finder implementation and export packages/drizzle/src/postgres/findDocumentLocks.ts, packages/drizzle/src/exports/postgres.ts
The lock finder uses package-local imports and BasePostgresAdapter as its receiver type. The Postgres package exports the function.
This change moves the Postgres document lock lookup into the shared Postgres package and wires it into the Vercel Postgres adapter. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the affected package (db-vercel-postgres), the fix type, and the main change (reusing transactions for document lock checks). It matches the changeset, which moves findDocumentLocks in…
Description check
The description states the backport source (#19589), the prior lock fix (#19552), the Vercel Postgres pool exhaustion problem, and the concrete changes. It also lists the test plan and deferred work. …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the affected package (db-vercel-postgres), the fix type, and the main change (reusing transactions for document lock checks). It matches the changeset, which moves findDocumentLocks into @payloadcms/drizzle/postgres and reuses the active transaction under Read Committed and Read Uncommitted. The '(v3)' suffix marks the 3.x backport.
Full details: Description check
Explanation
The description states the backport source (#19589), the prior lock fix (#19552), the Vercel Postgres pool exhaustion problem, and the concrete changes. It also lists the test plan and deferred work. It is related to the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/db-postgres/src/index.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
packages/db-vercel-postgres/src/index.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
Written with AI
Description
Backports #19589 to
3.x, on top of the merged Postgres lock fix in #19552. Vercel Postgres uses the same Drizzle transaction machinery and can exhaust its pool when a save holds a transaction connection while its document-lock read requests another connection.Changes
findDocumentLocksimplementation into@payloadcms/drizzle/postgresand register it in both Postgres adapters.Test Plan
pnpm run test:int:postgres test/locked-documents/int.spec.ts: 19 tests passed on3.x.pnpm exec tsc -b packages/db-postgres packages/db-vercel-postgres --pretty false: passed with the v3 lockfile dependencies installed.git diff --checkpassed.Dedicated Vercel Postgres test coverage and CI integration remain deferred to a separate follow-up, matching #19589. Hosted Vercel/WebSocket transport was not exercised.