Will pgbouncer allow multiple pools to same database pool name but different users?

All we need is an easy explanation of the problem, so here it is.

or, in other words, is it possible to do this:

[databases]
db1   = user=usr1 pool_size=10 application_name=app1 dbname=data1 ...
db1   = user=usr2 pool_size=20 application_name=app2 dbname=data1 ...

such that when usr1 attempts to connect to db1, they have pool_size of 10 while usr2 attempting to connect to same pool has 20?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

That won’t work for at least two reasons. The two rows are keyed alike, so only the 2nd will take affect. And those lines are not testing what the user is, they are commanding what the user will be. So connections coming in to pgbouncer for ‘db1’ will go to the real database as user ‘usr2’ (regardless of the specified incoming user) and as dbname ‘data1’

To do what you seem to want, you would need something like:

[databases]
db1 =  dbname=data1
[users]
usr1 = max_user_connections=10
usr2 = max_user_connections=20

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply