Re: Allow non-superuser to cancel superuser tasks.

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Alexander Kukushkin <cyberdemn@gmail.com>, "Andrey M. Borodin" <x4mmm@yandex-team.ru>, Michael Paquier <michael@paquier.xyz>, Kirill Reshke <reshkekirill@gmail.com>, "Leung, Anthony" <antholeu@amazon.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2024-11-22T19:21:53Z
Lists: pgsql-hackers

Attachments

On Fri, Nov 22, 2024 at 12:13:49PM -0500, Andres Freund wrote:
> I justed ended up looking at this code for some boring reason. One thing that
> has me worried a bit is that pg_signal_backend() now does
> pgstat_get_beentry_by_proc_number(), triggering a pgstat_read_current_status()
> further down.
> 
> pgstat_read_current_status() can be fairly expensive, both in CPU and in
> memory. It copies each proc's activity strings, which each can be 1kB by
> default!

Thanks for bringing this to my attention.

> I think it'd be better to introduce something that fetches a live
> BackendType. We have such functionality already, see
> pgstat_get_backend_current_activity().

Here is a draft-grade patch for this one.  It seems pretty
straightforward...

-- 
nathan

Commits

  1. Look up backend type in pg_signal_backend() more cheaply.

  2. Add tap test for pg_signal_autovacuum role

  3. Introduce pg_signal_autovacuum_worker.

  4. Add a slot synchronization function.

  5. Ban role pg_signal_backend from more superuser backend types.