pgbouncer's authenticator query should not use template1 database for connection
In Postgres, you cannot create a database if another session is using template1
.
Consequently, it's currently impossible to create a database by connecting to the primary via the service (DNS), if pgbouncer is enabled. Since pgbouncer authenticator query connects currently to template1
and doesn't close the connection, and authenticator query runs before user connection is established, obviously, user cannot create a database via the service.
Fix: change the database authenticator query connects to. It could be the postgres
database, for example.