Skip to content

"Transaction used after it was closed" - can I request new query executor? #2966

Answered by simolus3
gospodarp asked this question in Q&A
Discussion options

You must be logged in to vote

The intended behavior is that, after the transaction block completes, the logical transaction is ending as well. Drift goes quite a length to achieve that (for instance, streams watching a drift query in a transaction will also close their listeners afterwards). We need to do that because transactions need an explicit COMMIT statement, and we can't know that your timer action is read-only (if it weren't, should it implicitly run outside of the transaction? that can lead to some hard-to-debug correctness issues for the more common case where you simply forgot an await). So tldr, everything happening in a transaction block needs to be done accessing the database when it completes.

// (I am…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by gospodarp
Comment options

You must be logged in to vote
1 reply
@simolus3
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants