Repository navigation
fix(orm): clients derived from a transaction client use their own plugins and auth #2899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
evgenovalov
wants to merge
4
commits into
zenstackhq:dev
Choose a base branch
from
evgenovalov:fix/tx-derived-client-plugins
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2be61f6
fix(orm): clients derived from a transaction client use their own plu…
be8ab11
fix(orm): fail derived transaction clients once the transaction has e…
bf0cb7a
Merge branch 'dev' into fix/tx-derived-client-plugins
evgenovalov f253104
fix(orm): give onKyselyQuery hooks the proxied client
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hook queries on a transaction client deadlock while the outer query holds the connection.
For
tx.$use(lookupPlugin).user.count(), theonKyselyQueryhook receives the client bound to the running executor. If the hook awaitsclient.$unuse('lookup').user.count()before callingproceed(query), the inner query resolves to the same transaction connection provider. That provider is already held by the outer query. The inner query waits for the outer query to finish, and the outer query waits for the hook, so the transaction hangs. Removing the plugin stops hook recursion but does not remove this wait.Give hooks a client that runs on the held connection without acquiring the transaction provider again. The current remedy is a design change, so no localized diff is proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed, but this is not introduced here: on
dev, anonKyselyQueryhook that awaits a query on itsclientinside any$transactionalready hangs the same way (Kysely'sSingleConnectionProvideris not reentrant). This PR makes derived clients behave liketxitself. Giving hooks a client bound to the held connection is an executor-wide change for allonKyselyQueryplugins, so I'd rather track it separately than fold it in here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
Length of output: 29803
Script executed:
Length of output: 13380
Script executed:
Length of output: 1391
@evgenovalovThanks for confirming that a similar deadlock occurs ondev. I agree that the broader fix can be handled separately.One distinction: on
dev, a hook added only throughtx.$use(...)is not selected by the reused transaction query builder. This PR invokes that hook, so it exposes the existing limitation in that case. I’m not marking the finding as addressed.You are interacting with an AI system.