Re: Is RecoveryConflictInterrupt() entirely safe in a signal handler?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is RecoveryConflictInterrupt() entirely safe in a signal handler?
Date: 2022-04-09 21:00:41
Message-ID: 4185146.1649538041@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> Unlike most "procsignal" handler routines, RecoveryConflictInterrupt()
> doesn't just set a sig_atomic_t flag and poke the latch. Is the extra
> stuff it does safe? For example, is this call stack OK (to pick one
> that jumps out, but not the only one)?

> procsignal_sigusr1_handler
> -> RecoveryConflictInterrupt
> -> HoldingBufferPinThatDelaysRecovery
> -> GetPrivateRefCount
> -> GetPrivateRefCountEntry
> -> hash_search(...hash table that might be in the middle of an update...)

Ugh. That one was safe before somebody decided we needed a hash table
for buffer refcounts, but it's surely not safe now. Which, of course,
demonstrates the folly of allowing signal handlers to call much of
anything; but especially doing so without clearly marking the called
functions as needing to be signal safe.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-04-09 21:39:16 Re: Is RecoveryConflictInterrupt() entirely safe in a signal handler?
Previous Message Tom Lane 2022-04-09 20:38:25 Re: [HACKERS] WIP aPatch: Pgbench Serialization and deadlock errors