fix(plugin-multi-tenant): serialize transaction dataloader finds#16463
Open
cyphercodes wants to merge 1 commit intopayloadcms:3.xfrom
Open
fix(plugin-multi-tenant): serialize transaction dataloader finds#16463cyphercodes wants to merge 1 commit intopayloadcms:3.xfrom
cyphercodes wants to merge 1 commit intopayloadcms:3.xfrom
Conversation
|
@cyphercodes thanks for the quick turnaround! |
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.
What?
Serialize
payloadDataLoader.findcalls only while a request is running inside a transaction. This prevents multiple relationship/filterOptions validators from issuing concurrent MongoDB operations on the same transaction session.Why?
The multi-tenant plugin auto-injects relationship
filterOptions. Array rows are validated in parallel, so creating a tenant-scoped document with several relationship rows can trigger concurrentpayload.findcalls in the same MongoDB transaction and surface falseinvalid relationshipvalidation errors.How?
getDataLoaderfor transactional finds.Fixes #16462
Verification
pnpm exec vitest run --project unit packages/payload/src/collections/dataloader.spec.tspnpm exec vitest run --project int test/plugin-multi-tenant/int.spec.ts -t 'should create an array of same-tenant relationships without transaction races' --no-cachepnpm exec vitest run --project int test/plugin-multi-tenant/int.spec.ts --no-cachepnpm exec prettier --check packages/payload/src/collections/dataloader.ts packages/payload/src/collections/dataloader.spec.ts test/plugin-multi-tenant/int.spec.tspnpm exec eslint --flag v10_config_lookup_from_file packages/payload/src/collections/dataloader.tspnpm exec eslint --flag v10_config_lookup_from_file --no-warn-ignored packages/payload/src/collections/dataloader.spec.tsNODE_OPTIONS=--max-old-space-size=4096 pnpm exec eslint --flag v10_config_lookup_from_file --cache --cache-strategy content --no-error-on-unmatched-pattern test/plugin-multi-tenant/int.spec.ts(passes with existing warnings fortokenandblueDogTenantID)pnpm --filter payload build:swcgit diff --checkNote: a combined ESLint run over both changed non-spec files hit local Node heap/timeout limits, so I verified the files separately.