prisma: Issues with PgBouncer on DigitalOcean - `CODE: 26000 ERROR: prepared statement \"PGBOUNCER_34\" does not exist`

Bug description

I use prisma 5.5.2, with pgbouncer=true in the connection string. I get the following error: CODE: 26000 ERROR: prepared statement \"PGBOUNCER_34\" does not exist max_prepared_statements is as default (0)

Strangely enough it used to work before with pgbouncer=true without any issues. The issue started a few hours ago. DigitalOcean is also investigating this meanwhile

How to reproduce

Using digitalocean postgres pool with prisma does not work.

Expected behavior

No response

Prisma information

N/A

Environment & setup

  • OS: macOS or linux both not working
  • Database: PostgreSQL
  • Node.js version: 18 LTS

Prisma Version

5.5.2

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Reactions: 2
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@JelteF In your experience, what is the correct way to recover PgBouncer when one gets a prepared statement \"PGBOUNCER_34\" does not exist error message, meaning that PgBouncer thinks there is a prepared statement but it does not exist any more on the connection?

The server connection is fried at this point so it needs to be forcibly closed. There’s two ways of doing that:

  1. restarting pgbouncer
  2. Running RECONNECT in pgbouncer its admin console

It very much sounds like max_prepared_statements is not actually set to 0. The PGBOUNCER_36 name for the prepared statement is only used by PgBouncer when max_prepared_statements is set to a non-zero value.

In case it’s useful to others. I opened a ticket to DO and they disabled prepared statements for pgBouncer. After they made the change, I had to add again &pgbouncer=true to the connection string, otherwise I was getting the usual error. Anyway, I’ll keep monitoring the situation in the upcoming days.

Thanks all for your support.

@janpio

Are you sure that no Client still connects with pgbouncer=true?

Yes, I am pretty sure. I only have 3 clients.

@JelteF I am not aware of any way to interact with pgBouncer directly on a managed database on DO. But I opened a ticket asking for help.

Thanks for your help!