Skip to content

Commit

Permalink
feat(compute): Set default application_name for pgbouncer connections
Browse files Browse the repository at this point in the history
When client specifies `application_name`, pgbouncer propagates it to
the Postgres. Yet, if client doesn't do it, we have hard time figuring
out who opens a lot of Postgres connections (including the `cloud_admin`
ones).

I haven't found this documented, but it looks like pgbouncer accepts
standard Postgres connstring parameters in the connstring in the
`[databases]` section, so put the default `application_name=pgbouncer`
there. That way, we will always see who opens Postgres connections. I
did tests, and if client specifies a `application_name`, pgboucner overrides
this default, so it only works if it's not specified or set to blank
`&application_name=` in the connection string.

I think this is the last place we could potentially open some Postgres
connections without `application_name`. Everything else should be either
of two:
1. Direct client connections without `application_name`, but these
   should be strictly non`cloud_admin` ones
2. Some ad-hoc internal connections
so if we will see spikes of unidentified `cloud_admin` connections, we
will need to investigate it again.

Fixes neondatabase/cloud#20948
  • Loading branch information
ololobus committed Dec 2, 2024
1 parent 2e9207f commit 33ea9b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compute/etc/pgbouncer.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[databases]
*=host=localhost port=5432 auth_user=cloud_admin
;; pgbouncer propagates application_name (if it's specified) to the server, but some
;; clients don't set it. We set default application_name=pgbouncer to make it
;; easier to identify pgbouncer connections in Postgres. If client sets
;; application_name, it will be used instead.
*=host=localhost port=5432 auth_user=cloud_admin application_name=pgbouncer
[pgbouncer]
listen_port=6432
listen_addr=0.0.0.0
Expand Down

0 comments on commit 33ea9b1

Please sign in to comment.