Skip to content

fix: pass req to lock status reads so they use the transaction connection - #18447

Open
benjaminkincses wants to merge 2 commits into
payloadcms:mainfrom
benjaminkincses:fix/lock-status-req-transaction
Open

benjaminkincses wants to merge 2 commits into
payloadcms:mainfrom
benjaminkincses:fix/lock-status-req-transaction

Conversation

@benjaminkincses

Copy link
Copy Markdown
Contributor

Fixes #18406.

checkDocumentLockStatus looked up locked documents without passing req, so on Postgres the read grabbed a fresh pool connection instead of the running transaction. With overrideLock: false, concurrent updates and deletes hold their transaction connection and then wait on the pool for the lock read. Past pool.max parallel operations, everything deadlocks.

The find calls now get req (undefined for mongoose, matching the deleteMany calls in the same file), in both the single path and the batched getLockedDocumentIds path.

Verified with a new unit spec, checkDocumentLockStatus.spec.ts, asserting req reaches both finds and stays undefined for mongoose. The new tests fail on pristine code and pass with the fix. tsc and eslint are clean on the changed files.

This branch has not been deployed

No deployments
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.

checkDocumentLockStatus reads locked documents without req, deadlocking the Postgres pool under concurrent update/delete

1 participant