Re: Interrupts vs signals

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Andres Freund <andres@anarazel.de>
Cc: Thomas Munro <thomas.munro@gmail.com>, Michael Paquier <michael@paquier.xyz>, Robert Haas <robertmhaas@gmail.com>, Fujii Masao <masao.fujii@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-02-13T17:11:52Z
Lists: pgsql-hackers

Attachments

On 29/01/2026 03:05, Heikki Linnakangas wrote:
> Here's a new rebased and massively re-worked patch.
> 
> The patches are split differently than in the previous version:
> - Patches 0001-0005 are just refactoring around recovery conflicts which 
> I posted on a separate thread [1]. Please review and comment there.
> - Patches 0006 and 0007 are small cleanups that could be applied early 
> (after updating the docs, as noted in TODO comment there).
> - All the interesting bits for this thread are in the last, massive patch.
> 
> To review this, I suggest starting from the new src/backend/ipc/ 
> README.md file. It gives a good overview of the mechanism (or if it 
> doesn't, that's valuable feedback :-) ). It also contains a bunch of 
> Open Questions at the bottom; I'd love to hear opinions and ideas on those.

New version attached. Lots of little cleanups, and a few more notable 
changes:

- Switched to 64-bit interrupt masks. This gives more headroom for 
extensions to reserve their own custom interrupts

- I mostly gave up on sending interrupts from postmaster to child 
processes. So postmaster still uses kill() to tell child processes to 
exit or do other things. There's a TODO section in the README about 
that, but this is fine for now.

- Implemented a RequestAddinInterrupt() function for extensions to 
request interrupt bits. (TODO: use it in one of the example extensions, 
to show how to use it and to test that it works)

> On 15/07/2025 18:50, Andres Freund wrote:
>>> @@ -205,6 +206,8 @@ StartupProcExit(int code, Datum arg)
>>>      /* Shutdown the recovery environment */
>>>      if (standbyState != STANDBY_DISABLED)
>>>          ShutdownRecoveryTransactionEnvironment();
>>> +
>>> +    ProcGlobal->startupProc = INVALID_PROC_NUMBER;
>>>  }
>>
>>
>> What if we instead had a ProcGlobal->auxProc[auxproxtype]? We have 
>> different
>> versions of this for different types auf aux processes, which doesn't 
>> really
>> make sense.
> 
> I like that idea, but didn't try it yet.

The attached patches move a little in that direction. There's no array 
like that, but I moved the responsibility of setting those 
startupProc/walreceiverProc/checkpointerProc fields to 
InitAuxiliaryProcess(), so there's now a clear pattern to copy if other 
processes need to be advertised like that.

- Heikki

Commits

  1. Ignore SIGINT in walwriter and walsummarizer

  2. Split WaitEventSet functions to separate source file

  3. Use ModifyWaitEvent to update exit_on_postmaster_death

  4. Remove unused ShutdownLatchSupport() function

  5. Rename two functions that wake up other processes

  6. Use ProcNumbers instead of direct Latch pointers to address other procs

  7. Clean up WaitLatch calls that passed latch without WL_LATCH_SET

  8. Remove unneeded #include

  9. Remove unused latch

  10. Remove support for background workers without BGWORKER_SHMEM_ACCESS.