Timed out fetching a new connection from the connection pool prisma

Viewed 457

I have a nestjs scheduler which will run every one hour

I'm using multiple library to connect to postgres database through nestjs app

  1. prisma
  2. Knex

I have scheduler table that will have url to run on what datetime & a rule table that will have tablename, columnname, logicaloperator(i.e >,<,=,!=) & conditional operator(AND, OR) knex will create a query that is stored in database

for(const t of schedules) {
    //this wont stop and will make call simultanously to url
    fetch("url").catch()
}

the url will insert records it will take 1, 2, 3 hrs depending on the url but after certain time i'm getting Timed out fetching a new connection from the connection pool prisma error is it because i'm using multiple client to connect database?

1 Answers

You can configure the connection_limit and pool_timeout parameters while passing them in the connection string. You can set the connection_limit to 1 to make sure that prisma doesn't initiate new database connections, this way you won't get timeout errors.

Increasing the pool timeout would give the query engine more time to process queries in the queue.

Reference for connection_limit and pool_timeout parameters: Reference.

Related