This really helps PostgreSQL Azure service as well. When we are doing the upgrades to the service, instead of abruptly terminating the sessions we can provide this message.
Thanks,
Satya
From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Pavel Stehule Sent: Monday, June 19, 2017 11:41 AM To: Daniel Gustafsson <daniel@yesql.se> Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org> Subject: Re: [HACKERS] Optional message to user when terminating/cancelling backend
2017-06-19 20:24 GMT+02:00 Daniel Gustafsson <daniel@yesql.se>:
When terminating, or cancelling, a backend it’s currently not possible to let the signalled session know *why* it was dropped. This has nagged me in the past and now it happened to come up again, so I took a stab at this. The attached patch implements the ability to pass an optional text message to the signalled session which is included in the error message:
FATAL: terminating connection due to administrator command: "server rebooting"
Omitting the message invokes the command just like today.
The message is stored in a new shmem area which is checked when the session is aborted. To keep things simple a small buffer is kept per backend for the message. If deemed too costly, keeping a central buffer from which slabs are allocated can be done (but seemed rather complicated for little gain compared to the quite moderate memory spend.)