Hello, we have a weird case with connection poolin...
# orm-help
j
Hello, we have a weird case with connection pooling and interactive transactions. We have a pool size of max 3 connections. We open an interactive transaction and also execute queries that aren’t bound to this transaction at the same time
The issue is that prisma doesn’t create other connections to the database while our interactive transaction is running
It get stuck to 1 connection and eventually the transaction throws a timeout error
because the other queries are awaited inside the transaction, so the transaction is stuck as prisma isn’t creating one more connection
Is there any issue about prisma being unable to create new connections even if we didn’t reach the max connection limit in the pool?
d
An interactive transaction (itx) completely removes one connection from the pool until that itx finishes in some form. You'd have to elaborate on the "gets stuck on 1 connection" part, because the pool should have two other connections to work with to execute non-itx queries coming in.
j
@dpetrick This is our issue, the pool has only one connection, even if we set 3 max connection as parameter
So it seems that at some point either prisma lose those 2 connections and can’t / doesn’t know it has to create them back, or it never created them from the start
we don’t have the issue in all of our environments but when it happens we have CI failures 😛
I don’t know how to investigate this issue further
d
I'm not 100% sure if related, but we're currently investigating pooling issues and will release a fix for a deadlocked pool soon. To be clear: First thing you do when you connect to prisma is open an itx, then try to run more queries? That will lead to no more connections being opened?
j
@dpetrick The main issue is isn’t really transaction related, it’s that prisma is stuck at 1 connection in the pool, it doesn’t create new connections (it could create up to 3)
We restarted our container hosting our prisma code and made several tests but couldn’t reproduce so far
Like killing all the connections postgres’ side, next http request prisma is recreating 3 connections as expected. Killing 2 out of 3 connections, next http request prisma is recreating 2 connections as expected.
But as some point something is happening in some of our PR and prisma is stuck at a fixed number of connections and can’t create new ones.
d
That sounds related to our current pooling investigation then. We already have a fix ready to ship in the next release for that, which hopefully solves your issues too. I can also offer to notify you when you can use a dev build to test this sooner than release.
j
Great news, thanks for all the answers @dpetrick!