Re: HOLD_INTERRUPTS() vs ProcSignalBarrier

From: Andres Freund <andres(at)anarazel(dot)de>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HOLD_INTERRUPTS() vs ProcSignalBarrier
Date: 2022-05-25 03:08:01
Message-ID: 20220525030801.kb4kgf6pntlftyld@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2022-05-25 14:47:41 +1200, Thomas Munro wrote:
> My question is: do we really need to suppress these non-ereporting
> interrupts in all the places we currently do HOLD_INTERRUPTS()?

Most of those should be fairly short / only block on lwlocks, small amounts of
IO. I'm not sure how much of an issue this is. Are there actually CFIs inside
those HOLD_INTERRUPT sections?

> The reason I'm wondering about this is because the new ProcSignalBarrier
> mechanism has to wait for any HOLD_INTERRUPTS() sections across all backends
> to complete, and that possibly includes long cleanup loops that perform disk
> I/O. While some future ProcSignalBarrier handler might indeed not be safe
> during eg cleanup (perhaps because it can ereport(ERROR)), it is free to
> return false to defer itself until the next CFI.
>
> Concretely, for example, where xact.c holds interrupts:
>
> /* Prevent cancel/die interrupt while cleaning up */
> HOLD_INTERRUPTS();
>
> ... or where dsm_detach does something similar, there is probably no
> reason we should have to delay a ProcSignalBarrier just to accomplish
> what the comment says. Presumably it really just wants to make sure
> it doesn't lose control of the program counter via non-local return.

I don't think that's quite it. There are elog(ERROR) reachable from within
HOLD_INTERRUPTS() sections (it's not a critical section after all). I think
it's more that there's no point in reacting to interrupts in those spots,
because e.g. processing ProcDiePending requires aborting the currently active
transaction.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-05-25 03:09:09 Re: PG15 beta1 sort performance regression due to Generation context change
Previous Message Amit Langote 2022-05-25 03:00:47 Re: First draft of the PG 15 release notes