P
Prisma4mo ago
daniel

Connection Pool Timeout Issue Despite Custom Limit

I'm intermittently encountering a "Timed out fetching a new connection from the connection pool" error, even though I’ve set a custom connection limit of 70: Invalid prisma.entity.findFirstOrThrow() invocation: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 70) Could you help me understand why this is happening and if there's something I might be doing wrong? Thanks!
Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
4 Replies
Kazaz
Kazaz4mo ago
I'm actually having the same issue! Can someone help me understand it? More info I can share: 1. The DB can handle the connections. I have about 200+ connections on RDS that can handle about 900 connections. 2. I have 2 vCPU on my machine, but I've set the connection pool to 70. From what I can see the default behavior is num of cores * 2 + 1 - why is that? I saw that the query engine is not opening multiple threads, so why is there even a connection between the cores and the connections? 3. There are no long running queries. Checked that. Could number 2 be the reason I'm seeing the timeout error? The fact the query engine can't handle so many connections in the pool for such low end machine with only 2 vCPU?
Nurul
Nurul4mo ago
Can you please enable metrics and check the number of active/busy/idle database connections? https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/metrics This should help in debugging. Also if you are using postgres, try running this SQL to check the number of database connections and the service name which occupies these connections. SELECT * FROM pg_stat_activity;
Metrics (Preview) | Prisma Documentation
Diagnose application performance with insights into Prisma Client database activity.
Kazaz
Kazaz4mo ago
Thanks @Nurul ! We'll give it a try and report @Nurul (Prisma) Let's continue the chat here instead: https://discord.com/channels/937751382725886062/1280433844314574870/1280855789703135262 @daniel please also follow the conversation there (me and Daniel know each other, so it's cool)
leosilvadev
leosilvadev3mo ago
I am also having the same issues. We are running on postgres and I see that there are quite of connections opened, idle and many of those connections seem to no be picked up from the pool (as they are idle for like 20 minutes), still getting timeout while trying to get a connection from the pool
Want results from more Discord servers?
Add your server