0
  • Postgres 14
  • prisma 2
  • Azure Database

Faced an error during seeding development DB

remaining connection slots are reserved for non-replication superuser connections

I found that this error is caused by lack of connection pool. After some struggling, I failed. Here are my tries.

  • checked session leaks(not found)
  • increase 'max_connections' value in /etc/postgresql/14/postgresql.conf
  • reboot DB
  • reboot local node.js app which uses the remote DB

Full logs are below.

 PrismaClientUnknownRequestError: 
  Invalid `prisma.problem.create()` invocation in
  /myproject/api/prisma/seed.ts:448:43
  
    445 
    446 await Promise.all(
    447   problemData.map(async (data) => {
  → 448     const newOne = await prisma.problem.create(
    Error in connector: Error querying the database: db error: FATAL: remaining connection slots are reserved for non-replication superuser connections
      at RequestHandler.request (/myproject/api/node_modules/@prisma/client/runtime/index.js:49026:15)
      at async PrismaClient._request (/myproject/api/node_modules/@prisma/client/runtime/index.js:49919:18)
      at async /myproject/api/prisma/seed.ts:448:22
      at async Promise.all (index 11)
      at async main (/myproject/api/prisma/seed.ts:446:3) {
    clientVersion: '3.15.2'
  }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

An error occured while running the seed command:
Error: Command failed with exit code 1: yarn seed
user14082
  • 311
  • 3
  • 10
  • Fix your session leak. – Laurenz Albe Jun 27 '22 at 05:53
  • already checked several times. thanks anyway – user14082 Sep 15 '22 at 04:46
  • Yes, that can be difficult to find. We cannot really help without knowing your code. One clue might be the last statement run, which you can get in `pg_stat_activity`. But of course, if that was `COMMIT`, you are probably as wise as before. Another thing you could try is follow the TCP port to the application server thread that belongs to a connection, break into it with a debugger and figure out where in the code you are and why. – Laurenz Albe Sep 15 '22 at 06:07

0 Answers0