pgbouncer
pgbouncer copied to clipboard
Client terminate message
Does pgbouncer send clients a termination message when shut down?
I've been doing some testing with pgbouncer as an independently scalable and deployable middle tier between an application and a database. Holding a connection open and doing queries during a shutdown doesn't yield a friendly termination message like I would expend when shutting down the database.
Observed:
$ psql
psql (13.2 (Ubuntu 13.2-1.pgdg18.04+1), server 11.10)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
my_database=> select 1;
?column?
----------
1
(1 row)
my_database=> \watch 1
...
Fri Aug 13 04:24:15 2021 (every 1s)
?column?
----------
1
(1 row)
# --- pgbouncer is SIGTERMed ---
SSL SYSCALL error: EOF detected
The connection to the server was lost. Attempting reset: Succeeded.
psql (13.2 (Ubuntu 13.2-1.pgdg18.04+1), server 11.10)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Is there a cleaner way to tell pgbouncer to shut down and close client connections in a friendly way? I could only find SIGINT which would do a PAUSE and SHUTDOWN, but that seems to be about draining server connections, not client connections?
I don't think there is anything else than what you have already discovered.
Righto. Would a patch to add clean client connection draining be accepted? Perhaps a DRAIN command? and/or sending a termination message when closing client connections?
I don't know that we need a new command. Shouldn't it just be part of SHUTDOWN?