-
Notifications
You must be signed in to change notification settings - Fork 419
Ability to support pgbouncer with transaction pool_mode #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can already prevent the use of named prepared statements with |
I still think that fixing pgbouncer to handle the connection affinity at least in the anonymous |
It is still two roundtrips from client to server not one and connection will be pinned to client between them. More then that the latency will be higher. Network costs are the most notable for simple queries.
I don't see how |
You still need
This is one of the reasons why the cache is there in the first place. Two roundtrips is the minimum for the extended-query protocol. |
From the source codes of pgbouncer it looks like sending Parse/Bind/Describe/Execute/Sync should work (with exactly one terminating Sync) and this can be done in a one packet with one roundtrip. Still need some tests though. |
Yep, simple tests show what |
The introspection query should not be a problem, it is treated as a separate query, after which the original query flow is restarted (if anonymous statements are used), or continued (if a named prepared statement was used in |
Implemented in the fork: https://github.com/my-mail-ru/asyncpg Feel free to close this issue. |
This is a valid issue, and advertising a fork with a rejected patch is not a resolution, so this should remain open until an acceptable fix is implemented. |
OK. Hope someday we can switch to use upstream version. |
I have a use case (many distributed processes) across many machines that use pgbouncer in txn mode to drop connection count. All processes call a single stored-proc for writing to the database.
Is there an option here for me to interpolate the args and provide a single query with no args, explicitly tell asyncpg to not prepare, and meet your requirements? I'm not dealing with user input, don't need to be concerned about input validation, etc. |
Any news on this? I basically have the same use-case: many different distributed processes that I want to multiplex on a few pgbouncer connections in transaction mode. |
I haven't had time to work on this properly yet. I described a way to fix this in #348 (comment), so if anyone wants to take a stab at it, I'll be happy to review. |
#493 was merged a while ago, so I guess we can close this one. |
I have seen previous discussions on this topic (#121 (comment)), but still have use case where using
pool_mode=session
is not an option. We used to operate clusters of applications distributed over tenths to hundreds servers with dozens processes running asynchronous event loop on each. Every process has connection pool to allow several concurrent requests to the database to be processed at the same time. All of this gives us over thousand open connections to the database (most of them are idle because we query PostgreSQL not on every incoming request). The only solution to handle this without impact on PostgreSQL performance is to use pgbouncer inpool_mode=transaction
.We have plans to provide a PR allowing to disable prepared statements. Are you still solid in your opinion or we can agree to merge this feature to upstream?
The text was updated successfully, but these errors were encountered: