If you are using pgBouncer, but do not set the flag you will get an error message similar to this:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("26000"), message: "prepared statement \"s0\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(505), routine: Some("FetchPreparedStatement") }) }) })
TODO: We might want to catch this and output something useful (link to new docs page)
Prisma Client now has a flag
forceTransactions(temporary name, might be changed) that can be set totruein the constructor, to enable a "transaction mode", where each query is wrapped in a transaction:This is useful for usage with pgBouncer, which in transaction mode only works correctly with Prisma Client when used in combination with this flag.
TODO paragraph of why using pgBouncer might be wanted.
We need to properly document this in the docs so we have a location we can point users to.
Information
pgBouncer must run in
transactionmode. Other modes likesessiondo not make any sense because - see comment belowpgBouncer must be configured in the following way:
pg-bouncer#410 (comment) + waiting for Add PGBOUNCER_SERVER_RESET_QUERY_ALWAYS config heroku/heroku-buildpack-pgbouncer#129 to be merged for the third optionOn some hosting providers there might be no options to set these options directly via UI or otherwise. There you can try to log in to the server manually, and do the following (untested for now TODO)

More info: https://www.pgbouncer.org/usage.html#show-config
If you are using pgBouncer, but do not set the flag you will get an error message similar to this:
TODO: We might want to catch this and output something useful (link to new docs page)
Migration Engine and Introspection Engine will not work with pgBouncer (in transaction mode)

use the real database directly instead of the pgBouncer credentials to work around this
PR that merged the feature to Query Engine
prisma/prisma-engines#403
Related issues
prisma/prisma#556
prisma/prisma#1638
https://github.com/prisma/prisma-client-js/issues/228
#500
#410