Repository navigation
Replies: 12 comments 32 replies
|
Hello @MorenoMdz 👋 Thank you for providing a detailed description of the issue you are facing. 🙏 Can you check if the timeout errors go away if you use Node v16? It can help in confirming if this issue was indeed caused by the upgrade.
Based on my understanding, the number of active connections can change based on the number of incoming requests and the number of concurrent requests your application is handling at a time. If there's a sudden surge in incoming requests, your application will try to open more connections to the database to handle these requests, which can cause the connection limit to increase.
If your server only has 2 cores, then having a connection limit that's too high could potentially lead to resource exhaustion on the server. Can you try enabling metrics and check if any connections stay idle?
The number of connections allowed by your PostgreSQL server (or pgBouncer) should be configured based on your application's needs and your server's resources. There isn't a one-size-fits-all number for this. So, I think tweaking max connections number and timeout should be a good next step. |
That was my assumption as well, but doesn't that looks weird when the error says "limit", if the limit is dynamic it is not really a limit?
The DB server in this case right? Not the NestJs server as this one dynamically scales up and down. I am having some issues wrapping my head around the idea of 5 connections (2 cores * 2 +1) in the pool would be enough for for example a spike of 100 connections.
Right now it has the defaults, which for the connections limit seems to be dynamic so I am not getting the reason to manually edit it, more info about it is welcome hehe On the timeout I think I will try with 20s for now, is that reasonable? |
|
Sorry forgot the big question. Yes we tested in Node 16 and it does not crash. |
|
Hey @MorenoMdz. Let's start with the simple question:
The connection limit is either set via the And now:
What does
I assume this means that your app is configured to potentially use 15 instances of these Starter/0.5 core services if needed, so your app could potentially run 15 times?
Ok, so you have a PgBouncer that is configured to offer 33 connections to your apps maximum, correct?
What does that mean, I have not found anything googling for "Prisma Service package".
So your database server has 2 cores and allows maximum 31 connections?
Yes, increasing the pool timeout should allow more queries to be successful at the cost of worse UX of your app - waiting for 20s in a request is not a great experience. But you get less of those errors hopefully until we figure out what is really going on. Generally, a connection pool timeout error message means that on one server (instance), the Prisma Client connection pool could not give a new query a connection to be executed in the connection pool timeout of 10s. This happens when the pool was busy running other queries all that time, either because there were just too many queries, or the queries were too slow - or of course because the connection could not be opened in the necessary time. Right now the numbers above do not make sense to me. 17 or 33 connections per server, 15 instances, would mean many more potential database connections (33*15) than what I understand your PgBouncer and database to be configured (~30). I will need responses from you to these questions before we can continue. How much traffic does your app serve? |
|
One more question, for this case where we have a shared core, if we wanted to test a connection limit, should I try with 2? As 0,5 * 2 + 1 = 2? Would that be a max number of 2 connections per instance of our server? |
|
We are not seeing this error now when running with Node 20 and Prisma 5.1, I will mark this one as a potential solution for now but ill try to investigate more the issue. |
|
@janpio got and update from Render:
Does that mean Prisma might be reading the number of available CPUs incorrectly? |
|
Also seeing similar issues. Not exclusive to the latest version of Prisma (v5.1.1), but also the last v4 release. We've been testing on Node v20 and recently downgraded to Node v18 in case there may have been stability issues there. We're also running on Render, although across different environments (one with more CPU and memory, and one with less) and that doesn't seem to make a difference. Steps we've taken so far:
The thing is, we're seeing these connection pool timeouts happening with fairly low traffic. It generally gets triggered when there's a burst of traffic, but nothing that should overwhelm the number of connections set in the connection limit (e.g., we set the limit at 30 and get a burst of 30 requests). Maybe there's an issue with how the connection pooler recycles connections and makes them available. I do see there were issues with this in the past. |
|
I have the same problem when running in a github action. Locally, it works just fine. There are 10 connections in the pool. 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: 10)
at _n.handleRequestError (/__w/orm-benchmarks/orm-benchmarks/node_modules/@prisma/client/runtime/library.js:122:6927)
at _n.handleAndLogRequestError (/__w/orm-benchmarks/orm-benchmarks/node_modules/@prisma/client/runtime/library.js:122:6235)
at _n.request (/__w/orm-benchmarks/orm-benchmarks/node_modules/@prisma/client/runtime/library.js:122:5919)
at async l (/__w/orm-benchmarks/orm-benchmarks/node_modules/@prisma/client/runtime/library.js:131:9116)
at async Promise.all (index 18)
at getRowsWithRelations (/__w/orm-benchmarks/orm-benchmarks/src/prisma/benchmark-pg.ts:[57](https://github.com/alfateam/orm-benchmarks/actions/runs/9796288292/job/27050384191#step:6:58):5)
at benchmark (/__w/orm-benchmarks/orm-benchmarks/src/prisma/benchmark-pg.ts:28:5) {
code: 'P2024',
clientVersion: '5.16.1',
meta: { modelName: 'Order', connection_limit: 10, timeout: 10 }
```bash |
|
I tried with pool size 2 in github action - and it worked. https://github.com/alfateam/orm-benchmarks/actions/runs/9804768733/job/27073137829 |
|
Pool size 3 also worked fine in github action. |
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community! |







Uh oh!
There was an error while loading. Please reload this page.
Question
We started getting A LOT of pool timeout connection errors from Prisma since our last release yesterday. The release was basically some unrelated changes and upgrading the versions of the Node in our NestJs server from 16 to 20.
The errors look like this, 90% of the time from the same query:
But they also show with a different limit
Info:
Our server runs on a Render.com service that has a (0.5) half core configuration, and can scale up to 15 instances.
It connections to a Postgres pgBouncer that is set to 33 connections (15*2 + 1). Prisma is running using the Prisma Service package with default settings.
Questions:
How to reproduce (optional)
It happens randomly over the day, we can't tie it to a specific behavior yet.
Expected behavior (optional)
No response
Information about Prisma Schema, Client Queries and Environment (optional)
// Add your schema.prisma and relevant query codeAll reactions