pgbouncer icon indicating copy to clipboard operation
pgbouncer copied to clipboard

Client terminate message

Open sj26 opened this issue 4 years ago • 3 comments
trafficstars

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?

sj26 avatar Aug 13 '21 04:08 sj26

I don't think there is anything else than what you have already discovered.

petere avatar Aug 16 '21 16:08 petere

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?

sj26 avatar Aug 20 '21 05:08 sj26

I don't know that we need a new command. Shouldn't it just be part of SHUTDOWN?

petere avatar Aug 20 '21 10:08 petere