Skip to content
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

How to run a query outside of the transaction while in a transaction #81

Open
lpil opened this issue Jun 30, 2024 · 2 comments
Open

How to run a query outside of the transaction while in a transaction #81

lpil opened this issue Jun 30, 2024 · 2 comments

Comments

@lpil
Copy link
Contributor

lpil commented Jun 30, 2024

Hello!

There's a check that prevents a process from intentionally using another pool in a transaction or with a different connection from the same transaction, even if one is explicitly passed in by the programmer.

pgo/src/pgo.erl

Lines 95 to 98 in d1989c4

query(Query, Params, Options) ->
case get(pgo_transaction_connection) of
undefined ->
Pool = maps:get(pool, Options, default),

Is there an intended way around this? I would like full control over which pool is used, even if one of them is in a transaction state.

Thank you,
Louis

@lpil lpil changed the title How to run a query against another pool while in a transaction How to run a query outside of the transaction while in a transaction Jun 30, 2024
@tsloughter
Copy link
Collaborator

Maybe exposing query/4 will do it. It accepts a Conn. So to get around this you'd have to checkout a connection and pass it directly, to be explicit you are going around the transaction.

@lpil
Copy link
Contributor Author

lpil commented Jul 7, 2024

That would work! Sounds good

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

No branches or pull requests

2 participants