question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timed out fetching a new connection from the pool

See original GitHub issue

Bug description

After running my application for around 1-2 days, I start getting the following error:

prisma:client Error: Timed out fetching a new connection from the pool. Please consider reducing the number of requests or increasing the `connection_limit` parameter (https://www.prisma.io/docs/concepts/components/prisma-client/connection-management#connection-pool). Current limit: 10.

The same happened before with a connection limit of 3. Raising it to 10 seemed to have no effect.

After the error occurs once, no query will succeed anymore, the error will be thrown on any query and the application requires a restart (prisma will never recover from the error).

I checked whether the database has an issue, but it is working fine. SHOW PROCESSLIST shows that no connection is actually established.

How to reproduce

I have not found a way to reliably reproduce this yet. I always need to wait 1-2 days until the error randomly appears. I am running my application in debug mode with DEBUG=* for the last days, so if you need any additional information, I can look it up in the logs.

Expected behavior

No response

Prisma information

generator client {
    provider        = "prisma-client-js"
    binaryTargets   = ["native"]
}

datasource db {
    provider = "mysql"
    url      = env("DATABASE_URL")
}

I can’t post my complete prisma schema here. It doesn’t matter which queries are run, all of them fail with the same error.

Environment & setup

  • OS: Linux (official node:14 docker image)
  • Database: MySQL 8.0
  • Node.js version: 14

Prisma Version

prisma               : 2.21.2
@prisma/client       : 2.21.2
Current platform     : darwin
Query Engine         : query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/prisma/node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/prisma/node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : e421996c87d5f3c8f7eeadd502d4ad402c89464d
Studio               : 0.371.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:25 (13 by maintainers)

github_iconTop GitHub Comments

6reactions
TLaddcommented, Nov 7, 2021

I’ve been experiencing this as well. We get a temporary spike in requests to our app servers that increases memory and cpu near 100% for a short time. Prisma then seems to get stuck in a state of every query failing to fetch a connection and never recovers, even as cpu and memory usage drop. Restarting the servers returns things to normal. Wondering if https://github.com/prisma/prisma/issues/9584 is related since both seem to involve the client connections getting stuck in particular failure states.

5reactions
janpiocommented, Feb 23, 2022

We actually have a reproduction now (essentially load spike or resource constraint with specific parameters) and are working on understanding the problem (non surprisingly something with the connection pool) and hopefully fixing it (no ETA - but if you are able to somehow reproduce this, we are looking for testers of our fixes of course).

Some related issues: https://github.com/prisma/prisma/issues/11868 https://github.com/prisma/prisma-private/issues/160 (private with reproduction)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Timed out fetching a new connection from the connection pool ...
I have a nestjs scheduler which will run every one hour. I'm using multiple library to connect to postgres ...
Read more >
Connection pool - Prisma
The default connection pool timeout is 10 seconds. If the query engine does not process a particular query within that time, it throws...
Read more >
Resolve "Timeout waiting for connection from pool" error in ...
This error usually happens when you reach the Amazon EMR File System (EMRFS) connection limit for Amazon Simple Storage Service (Amazon S3).
Read more >
Using Prisma to Address Connection Pooling Issues in ...
The connection pool ensures that any database queries are within the connection and timeout limits that you have configured.
Read more >
Find opportunities to build and grow | Dentry.io
Error: Invalid `prisma.jobRole.findMany()` invocation: Timed out fetching a new connection from the pool. Please consider reducing the number of requests or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found