| From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
|---|---|
| To: | Jelte Fennema-Nio <me(at)jeltef(dot)nl> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tatsuo Ishii <ishii(at)postgresql(dot)org>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Dave Cramer <davecramer(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, jnasby(at)upgrade(dot)com |
| Subject: | Re: Add read-only disconnect_requested GUC for graceful client disconnect |
| Date: | 2026-11-28 23:48:17 |
| Message-ID: | CA+TgmoZ4uFWpMcXb15BYNOLZpB-3gGCVHJ3S6u3-_xGnmHhbFw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, Jul 11, 2026 at 4:16 AM Jelte Fennema-Nio <me(at)jeltef(dot)nl> wrote:
> This is a redesign of the previous GoAway proposal[4] but this time
> *without making any protocol changes*:
Hi,
I think this is a good idea. At the risk of making you crazy, I think
the previous proposal of making this a protocol extension i.e.
_pq_.goaway=1, was superior, because these disadvantages are real:
> Two notes of suboptimal behavior:
> 1. Proxies using this to report their own shutdown will cause the value
> of the ParameterStatus to be different than the value that
> "SHOW disconnect_requested" reports, unless they also intercept those
> queries.
> 2. Right now the ParameterStatus is only sent at completion of a query,
> not while a connection is idle. It'd be better if a connection pool
> could check the current state of idle connections too, before handing
> them off again. I'll address this in a follow-up commit once it's
> agreed on that the general approach is sensible.
If this works entirely at a protocol level, then there is no SHOW
command that can give a conflicting view of the same state, and the
message can be defined to be allowed at any point in the protocol
stream. As you said on the GoAway thread, conceptually this is a
link-level message.
I think, in general, that you've given this the right semantics. Jacob
mentioned in http://postgr.es/m/CAOYmi+mSn8xQ7ExqY07V6G2oFXN2nY+7f4yf_RV2=7xNCKwW-Q@mail.gmail.com/
asking or forcing clients to disconnect for security reasons, but
that's really a different problem. This is basically just informing
clients that the connection is being shut down, instead of not doing
that and then being sad.
AFAICS, the only real fly in the ointment here is whether clients
adopt it. But the lovely thing is that even if only pgbouncer adopts
it there is a meaningful gain, because pgbouncer can request this from
the server and benefit from it even if the application clients don't
ask for it from pgbouncer. That's pretty sweet. Compare that with
something like SCRAM where we really needed every client to pick it
up; AFAICT, they nearly all did, but that was a lot of work for a lot
of people, and this is cool in that it doesn't require it.
I quite agree with your statements elsewhere that smart shutdown is
pretty dumb, and this would make it significantly less dumb. +1 for
that.
--
Robert Haas
Databricks
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sho Ito | 2026-11-29 00:38:31 | Re: [PATCH] Improve tab completion after CREATE INDEX key list |
| Previous Message | Stepan Neretin | 2026-11-28 20:03:17 | Re: Restrict postgres_fdw/dblink passfile to user mappings |