prisma: Intermittent P1001 - "Can't reach database server..."
Bug description
While my app is running, I occasionally see logs for error P1001. The app continues to function and has access to the database for subsequent requests.
How to reproduce
This seems to be random, but seems to occur most often when the app is under load and has multiple connections to the database. The problem occurs on localhost DB and remote
Expected behavior
I’d like this error to provide more information. It is a strange error to receive while your app is actively connected to the database.
Prisma information
Environment & setup
- OS: Windows/Linux
- Database: 10.6.7-MariaDB
- Node.js version: 16
Prisma Version
Connector: MySQL/MariaDB
Prisma 3.15.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 17 (4 by maintainers)
Personally, I gave up using prisma because of this bug. Too unstable for enterprise use.
I also don’t understand why after months no one has considered this
I’m experiencing the same problem using Prisma 4.2.1 with AWS Lamba and RDS Postgres. A few times a day, we will get an error that it can’t reach our database, but nothing in the RDS metrics indicate that the database is doing anything unusual.
I work with @rflorence who commented a while back saying we were running into this error.
We solved this by upgrading our database to a bigger instance. The free memory it had was very low because we were running on a
t3.micro
RDS instance in AWS. Upgrading tot3.small
(or anything other thenmicro
) has solved this issue. The specific metric is “freeable memory” which was very low and it led to random db disconnections in our app. We missed this metric at first because it was consistently low on memory so there was no odd looking spike or dip whenever the errors occurred.tldr: make sure your db node has a lot of free memory. Hope that might help anyone else who has run into this issue.
● Test suite failed to run
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● CustomGC
In my case individual tests run fine but test suite fails at the end.
This is still an issue. We’re running into this on CI, our dev and prod.
Here’s a sample stack trace:
We have pool_timeout=0 so it should never time out on connection. There is something rotten in the prisma connection pooling implementation. The test which failed is our most DB heavy test-we have a lot of fixtures and DB calls in there.
Happens constantly on the first request for any Node service. The first request fails every time. Running the same code a second time, without restarting, it works perfectly. This is on a 32GB MacBook Pro M1 running the following:
@prisma/client : 4.4.0 prisma 4.4.0 node 16.17.0 macos 12.6 docker 20.10.17, build 100c701 docker compose 2.10.2
Have not looked into it, but it almost feels like the PrismaClient is using some type of singleton pattern and throwing the error prior to some underlying piece initializing. That could explain why subsequent calls succeed.