public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andrey Borodin <[email protected]>
To: Roman Khapov <[email protected]>
Cc: [email protected]
Subject: Re: Additional message in pg_terminate_backend
Date: Wed, 17 Dec 2025 16:34:09 +0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>



> On 13 Dec 2025, at 12:44, Roman Khapov <[email protected]> wrote:
> 
> Recently I started working on patch for adding additional message from admin 
> in pg_terminate_backend for one of our greenplum fork. The main idea is that there must be 
> done little investigation every time you see 'FATAL:  terminating connection due to administrator command’ to understand the reason, especially in cases where connection was terminated by another
> user. So it was decided to create some new functions, that allows to terminate connection with
> additional message.

Overall idea seems good to me.
Keep in mind that Postgres literals are translated into many languages. So text ought to be clear enough for translators to build a sentence that precedes termination reason.

> 
> I did POC patches with the next main ideas:
> - lets add termReasonStr field in every PGPROC, that field can be used in ProcessInterrupts() 
> - implementation of pg_terminate_backend/pg_cancel_backend should be accessible from extensions, so lets move it in pg_terminate_backend_impl/pg_cancel_backend_impl and add definitions for it somewhere
> - write simple extensions, which defines functions like pg_terminate_backend_msg, that sets termReasonStr and calls pg_terminate_backend_impl

First thing that we need to do is to agree on API of the new feature. We do not need core-extension separation for this.
My vote would be for having pg_cancel_backend(reason text)\pg_terminate_backend(reason text) along with parameterless versions.
32 bytes per PGPROC seems reasonable for a "reason". The patch doesn't seem to take care of cleaning "termReasonStr". Is it done elsewhere?
We have a race condition if many backends cancel same backend. Won't they mess each other's reason?

Thanks!


Best regards, Andrey Borodin.






view thread (8+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Additional message in pg_terminate_backend
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox