-
Notifications
You must be signed in to change notification settings - Fork 65
Document forceTransactions
/ pgBouncer
#503
Comments
Earlier notes from @pimeys on pgBouncer that we might want to incorporate into the documentation in some way: Pgbouncer is a lightweight connection pooler for PostgreSQL. Instead of running Typically postgres supports only a certain amount of concurrent connections and Transaction ModeNow pgbouncer can be run in three different modes, them being session, Session mode gives one connection per client, and is useful mainly to define Statement mode shares a connection with every query coming to the system. It Transaction mode offers a connection for every transaction. With this mode and
Downsides
|
We should also make sure to clean up https://github.com/prisma/prisma2/blob/master/docs/faq.md#how-to-handle-connection-pooling-for-prisma-client-js-in-serverless-environments when we do this. |
I think the I think the documentation of this option should focus on what it does, and only tangentially mention pgbouncer:
There should be separate documentation about how to use pgbouncer that mention this option. |
forceTransactions
forceTransactions
/ pgBouncer
Quick question - is this option supported in Prisma 1, or is this only available in Prisma 2? We are having the pgBouncer issue. |
This only refers to Prisma 2.x - for Prisma1 related questions you should open an issue at https://github.com/prisma/prisma1/ |
Internal Note: We need to do some more investigation before we actually document this: prisma/prisma#1638 (comment) |
We changed the implementation, so this needs different documentation. |
Prisma Client now has a flag
forceTransactions
(temporary name, might be changed) that can be set totrue
in 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
transaction
mode. Other modes likesession
do 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
The text was updated successfully, but these errors were encountered: