[PATCH] ProcessInterrupts_hook

From: Craig Ringer <craig(dot)ringer(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Petr Jelinek <petr(dot)jelinek(at)enterprisedb(dot)com>, Markus Wanner <markus(dot)wanner(at)enterprisedb(dot)com>
Subject: [PATCH] ProcessInterrupts_hook
Date: 2021-01-18 07:59:40
Message-ID: CAGRY4nzm+=ZBkWDaBXPQeHGqd5xAc4ukUR+Ph2mEeqj1j5ycRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi folks

A few times lately I've been doing things in extensions that've made me
want to be able to run my own code whenever InterruptPending is true and
CHECK_FOR_INTERRUPTS() calls ProcessInterrupts()

So here's a simple patch to add ProcessInterrupts_hook. It follows the
usual pattern like ProcessUtility_hook and standard_ProcessUtility.

Why? Because sometimes I want most of the behaviour of die(), but the
option to override it with some bgworker-specific choices occasionally.
HOLD_INTERRUPTS() is too big a hammer.

What I really want to go along with this is a way for any backend to
observe the postmaster's pmState and its "Shutdown" variable's value, so
any backend can tell if we're in FastShutdown, SmartShutdown, etc. Copies
in shmem only obviously. But I'm not convinced it's right to just copy
these vars as-is to shmem, and I don't want to use the memory for a
ProcSignal slot for something that won't be relevant for most backends for
most of the postmaster lifetime. Ideas welcomed.

Attachment Content-Type Size
v1-0001-Provide-a-hook-for-ProcessInterrupts.patch text/x-patch 2.5 KB
v1-0002-Test-for-ProcessInterrupts_hook.patch text/x-patch 10.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-01-18 07:59:51 Re: Narrow the scope of the variable outputstr in logicalrep_write_tuple
Previous Message Luc Vlaming 2021-01-18 07:58:08 Re: New Table Access Methods for Multi and Single Inserts