Skip to content
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

pgbouncer says "no such user" when it should be "no such database" #988

Open
dtseiler opened this issue Nov 28, 2023 · 3 comments
Open

pgbouncer says "no such user" when it should be "no such database" #988

dtseiler opened this issue Nov 28, 2023 · 3 comments

Comments

@dtseiler
Copy link

dtseiler commented Nov 28, 2023

Using pgbouncer 1.20.1 on Ubuntu 22.04 via the PGDG apt repo. The PG instance is PG 15, the DB name is hyphenated (eg "this-is-my-db"). I had a misconfig in the pgbouncer ini file where the hyphens were replaced with underscores in the DB name entry, but not in the actual connection.

So the ini entry would be something like:

[databases]
this_is_my_db = host=my-db-host.foo.com port=5432 dbname=this-is-my-db auth_user=pgbouncer

When I would try to connect to the database (using the hyphenated name) via psql from my workstation through the pgbouncer, it would fail (as you'd expect), but the error it would give me is no such user, a la:

2023-11-28 20:26:37.397 UTC [14907] LOG C-0x56384fed3ea0: (nodb)/(nouser)@10.23.34.56:54596 no such user: this-is-my-db

In my case the username I was attempting to log in with was the same as the DB name. I can set up a test with a name that is unique.

It took me a long time to catch the underscores vs hyphens thing so basically I'm wondering if this is a mistake in the error message. I can try whip up a concrete test case later tonight.

@dtseiler
Copy link
Author

Yeah I can duplicate when I login with a completely fake DB name that it is referring to the user name I give it on the psql command-line. On the client end I just see FATAL: password authentication failed, in the pgbouncer log I see the failed login attempt with no such user.

Maybe the (nodb) part of the log message should be the hint I need that something was wrong with the DB name? I'm basically just asking if we can make this error more clear/obvious for smooth-brained folks like myself.

@eulerto
Copy link
Member

eulerto commented Nov 30, 2023

$ psql -U xpto1 -d xpto2
psql: error: connection to server on socket "/tmp/.s.PGSQL.9916" failed: FATAL:  role "xpto1" does not exist

It uses the same pattern as Postgres. It checks the role before the database. Provide additional information for the login is not recommended for security reasons.

@dtseiler
Copy link
Author

dtseiler commented Dec 1, 2023

For security reasons I can see returning that error to the client attempting the connection. But in the pgbouncer log would it be possible to note that client attempted a connection to a non-existent database?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants