Hi, everyone. I currently have a server running on...
# orm-help
d
Hi, everyone. I currently have a server running on a Digital Ocean Droplet, connected to a hobby Heroku database. This is essentially my test environment that people are using with an early beta. When going live, that database will be replaced by a managed Postgres database, also on Digital Ocean. In the past week or so, I've started noticing issues and I'd guess it happened since upgrading to Prisma
2.15.0
as nothing else has changed. When I say issues, I mean things are either way slower than they normally are or they just don't work at all. Logging in, fetching products, etc. Stuff that's worked without issue for a few months now. I'm using Sentry and one of the recent issues shown from a client was:
Copy code
Error: GraphQL error: Error in connector: Error creating a database connection. (Timed out fetching a connection from the pool (connection limit: 3, in use: 0))
GraphQL error: Error in connector: Error creating a database connection. (Timed out fetching a c...
I've had this setup for a few months, updating the odd thing on the server every now and then, and it's been stable while I've been focusing on the client. Based off that error message alone, can anyone see if I've maybe missed something with the latest Prisma update or if there's anything else you recommend. Thanks! 🙂
d
I have also noticed this on 2.15.0, had to do a rollback.
d
Hi, @Dominic Hadfield. Thanks for letting me know. While it's a shame we both have the issue, it's good to know it's not just me. I'd try
2.16.0
but I use
nexus-plugin-prisma
and that's not been updated.
d
we do too, I found an issue on github that addresses this but the solution did not work: https://github.com/prisma/prisma/issues/5334
d
Ah, interesting. Thanks for sharing that.
If the 
connection_limit
 argument is omitted, the default number of connections is calculated according to this formula: 
num_physical_cpus * 2 + 1
 where 
num_physical_cpus
 represents the number of physical CPUs on your machine.
In my case then, testing on a $5 Droplet with one vCPU, I wonder how many connections were automatically calculated as I haven't specified an amount myself. 🤔 To be honest, I don't know much about this kind of thing.
d
we had a large instance on rds and set connection limit to 22 and timeout to 30s and it still threw this error
when we didnt specify with 2.15, it gave us the same error of a connection limit of 3
d
Hmm. Have you spoken directly to any of the Prisma team about this issue?
n
Hey Darryl and Dominic, thanks a lot for sharing! We're currently looking into this internally and will get back to you soon 🙂
👍 2
d
Not yet Darryl, but they are quite active on slack 😙
👍 2
d
Great. Thanks, @nikolasburk. Have a nice day. 🙂
d
@Darryl Could you check the
max_connections
config of your PostgreSQL instance? You can check that with the
SHOW config_file;
in the
psql
CLI.
d
Hi, @Daniel Norman. I unfortunately can't check right now but looking at Heroku's docs for their hobby (free) databases, it looks like they have a maximum of 20. https://devcenter.heroku.com/articles/heroku-postgres-plans#hobby-tier
👍 1
@Daniel Norman Seeing as it's a Heroku free database, I don't have superuser privelages to examine the "config_file" but I can run
SHOW max_connections;
and I see:
Copy code
max_connections
-----------------
 500
(1 row)
👀 1
d
Thanks @Darryl. I would assume that the DB connection limit is indeed
20
. The
max_connections
you got from PostgreSQL probably applies to the whole database instance. My hunch is that this is related to the latency between the DO droplet and the hobby Heroku DB. Because the hobby Heroku DBs use multi-tenancy their performance is very flaky. Either way, this is also related to Prisma’s connection pool and its timeout configuration which we are investigating. Could you try out setting
pool_timeout=0
in the DB connection string? This will ensure that there’s no timeout at all. In 2.15.0 we introduced a change that sets it to a default of 5 seconds. So it might be related.
d
Hi, @Daniel Norman. Sure, I'll try that but it'll likely only be in a couple of hours. I understand what you mean about the latency and the hobby database is only a temporary setup for testing (I'll have a Digital Ocean managed database in production). I've had this setup for a few months now, though, and I've only ever had issues like this in the past week. Thanks for your help so far. I'll let you know when I get chance to try it.
👌 1
n
@Dominic Hadfield just to make you aware, we found the root cause of the issue of Darryl's problem, Jan explained it here: https://github.com/prisma/prisma/issues/5485#issuecomment-775402837 Does this help with your issue as well?
d
I saw this this morning, yeah we have locked onto 2.14 for the near future. Thanks for the update
👍 2