Re: Interrupts vs signals

From: Greg Burd <greg(at)burd(dot)me>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Interrupts vs signals
Date: 2026-12-02 12:29:05
Message-ID: 179616488385.302686.11525335120623305199@burd.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 1, 2026 at 12:39 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> ProcessParallelQueryMessage() is a piece of terminological
> inexactitude: it's shared by everything that uses a ParallelContext,
> which is more than just queries.

Hi Robert,

I replicated the lost message that your LLM review found and naming is
hard, so v17 (32afcc29df9) addresses both. Heikki, these touch your
0001 and 0008; take or reshape them as you like.

It's now ProcessParallelContextMessage(), and the function that loops
over the contexts is ProcessParallelContextMessages().

> Instead of having ProcessParallelMessageInterrupt() call
> every function that might be interested, how about having a way for a
> backend to temporarily change the function that gets called, or a
> stack of functions to call?

I left this alone, since it's Heikki's design and I've not spent enough
time to have justification to change it.

When idle, the REPACK reader returns at a NULL check and the apply
reader walks an empty list, so the cost is two calls per message. A
registered set of readers would also cover the error case below without
the shared flag, which is an argument for it.

I'd have to spend more time in that to form a strong opinion, Heikki?

> It thinks the patch regresses behavior in the case
> where a parallel worker and an apply worker fail at the same time,
> because ParallelMessagePending will get cleared but only the parallel
> worker's message will get handled, since it throws an error. If the
> leader then catches that error, the process continues with a pending
> message but no flag set that will cause us to read it.

I confirmed your suspicion with an injection point that makes the first
reader throw once, inside a PL/pgSQL block that catches the error.

The attached v17 wraps the three readers in PG_TRY(). 0001's PG_CATCH()
sets the flag again, 0008's raises INTERRUPT_PARALLEL_MESSAGE again, and
both rethrow. With that change, the same probe runs the handler a
second time, which reads the queues the error skipped.

best.

-greg

Attachment Content-Type Size
v17-0003-Refactor-datachecksums-launcher-worker-comms-to-.patch application/octet-stream 5.7 KB
v17-0006-Remove-dependency-on-utils-resowner.h-just-for-R.patch application/octet-stream 3.0 KB
v17-0002-Use-WaitLatch-for-the-timeouts-in-recovery-confl.patch application/octet-stream 16.7 KB
v17-0007-Hold-spinlock-while-clearing-MyProc-pid-on-backe.patch application/octet-stream 1.3 KB
v17-0005-Rename-postmaster-interrupt.c-to-ipc-signal_hand.patch application/octet-stream 20.8 KB
v17-0001-Refactor-PARALLEL_MESSAGE-procsignal-signaling.patch application/octet-stream 19.0 KB
v17-0004-Move-CHECK_FOR_INTERRUPTS-and-friends-to-new-ipc.patch application/octet-stream 120.4 KB
v17-0008-Replace-Latches-with-Interrupts.patch application/octet-stream 535.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matheus Alcantara 2026-12-02 12:56:39 Re: [PATCH v1] Fix for Bug#19724 - ALTER TYPE ... ALTER ATTRIBUTE triggers internal error for base type of domain with check
Previous Message shveta malik 2026-12-02 12:11:42 Re: ALTER DEFAULT PRIVILEGES IN SCHEMA pg_conflict silently has no effect