P
Prisma5d ago
Éanna

Recommended pgbouncer usage for pgbouncer version > 1.21.0

Hi, I am using Prisma with Azure Postgres - Flexible Server. As my app is deployed on Vercel, I want to use pgbouncer. However, I seem to be encountering some issues. As per the docs, I have not set pgbouncer=true since the default version on Azure is 1.22.1 I am currently using DATABASE_URL and DIRECT_URL with the only difference between the connection strings being the port number (6432, 5432) respectively (no &pgbouncer=true) When deploying my application, I get errors related to prepared statements.
PrismaClientUnknownRequestError:
Invalid `prisma.organizationMember.create()` invocation:


Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(PostgresError { code: "42P05", message: "prepared statement \"s0\" already exists", severity: "ERROR", detail: None, column: None, hint: None }), transient: false })
at Ln.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:121:7943)
at Ln.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:121:7061)
at Ln.request (/var/task/node_modules/@prisma/client/runtime/library.js:121:6745)
at async l (/var/task/node_modules/@prisma/client/runtime/library.js:130:9633)
at async Object.p [as createMember] (/var/task/.next/server/pages/api/webhooks/clerk.js:1:5267)
at async l (/var/task/.next/server/pages/api/webhooks/clerk.js:1:2771)
at async K (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16853)
at async U.render (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:17492)
at async r6.runApi (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:44421)
at async r6.handleCatchallRenderRequest (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:38377) {
clientVersion: '5.19.1'
}
PrismaClientUnknownRequestError:
Invalid `prisma.organizationMember.create()` invocation:


Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(PostgresError { code: "42P05", message: "prepared statement \"s0\" already exists", severity: "ERROR", detail: None, column: None, hint: None }), transient: false })
at Ln.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:121:7943)
at Ln.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:121:7061)
at Ln.request (/var/task/node_modules/@prisma/client/runtime/library.js:121:6745)
at async l (/var/task/node_modules/@prisma/client/runtime/library.js:130:9633)
at async Object.p [as createMember] (/var/task/.next/server/pages/api/webhooks/clerk.js:1:5267)
at async l (/var/task/.next/server/pages/api/webhooks/clerk.js:1:2771)
at async K (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16853)
at async U.render (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:17492)
at async r6.runApi (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:44421)
at async r6.handleCatchallRenderRequest (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:38377) {
clientVersion: '5.19.1'
}
Also attached is my pgbouncer config. What am I doing wrong?
No description
2 Replies
Éanna
ÉannaOP5d ago
From reading the docs, it seems like this might relate to the max_prepared_statements parameter? What's a recommended value for this?
RaphaelEtim
RaphaelEtim3d ago
Hi @Éanna A value greater than zero should be fine as mentioned in the documentation
Configure Prisma Client with PgBouncer | Prisma Documentation
An external connection pooler like PgBouncer holds a connection pool to the database, and proxies incoming client connections by sitting between Prisma Client and the database. This reduces the number of processes a database has to handle at any given time.
Want results from more Discord servers?
Add your server