Skip to content

Prisma2 Application Potentially Creating DB Connections per API Request #1438

@robinwander

Description

@robinwander

I have had a prisma app running in GCP that connects to a postgres instance also running in GCP for about a day.

All API calls started failing to the app with:

2020-01-24 21:15:52.056 CSTError querying the database: db error: FATAL: remaining connection slots are reserved for non-replication superuser connections
2020-01-24 21:15:52.056 CST at PhotonFetcher.request (/app/node_modules/@prisma/photon/index.js:62:23)
2020-01-24 21:15:52.056 CST at runMicrotasks (<anonymous>)
2020-01-24 21:15:52.056 CST at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-01-24 21:15:52.058 CSTGET500395 B44 msChrome 79 https://flag-api-vykaoik56q-uc.a.run.app/switches

Looks like the app is holding open connections. I have basically the boiler plate from the prisma init:

import { GraphQLServer } from 'graphql-yoga';
import { schema } from './schema';
import { createContext } from './context';
import getSwitchesWithAuthHeader from './controllers/switches';
import * as cors from 'cors';

const server = new GraphQLServer({ schema, context: createContext });
server.express.use(cors());
server.express.get('/switches', getSwitchesWithAuthHeader);

server.start(
  { port: 8080 },

  () =>
    console.log(
      `🚀 Server ready at: http://localhost:8080\n⭐️ See sample queries: http://pris.ly/e/ts/graphql#5-using-the-graphql-api`,
    ),
);

Versions:

    "@prisma/photon": "2.0.0-alpha.538",
    "basic-auth": "^2.0.1",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "graphql": "14.5.8",
    "graphql-yoga": "1.18.3",
    "nexus": "0.12.0-rc.5",

Restarting my database or the application fixes the issue temporarily.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions