| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | Greg Burd <greg(at)burd(dot)me>, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, 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 15:38:41 |
| Message-ID: | ee2a12a6-89f0-4ac0-9939-7953266453de@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 02/12/2026 14:29, Greg Burd wrote:
> On Tue, Dec 1, 2026 at 12:39 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> 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.
Right, that's the straightforward bandaid that Claude suggests.
Stepping back, the problem is that if processing the message throws an
error, any other messages that might be pending won't be processed. That
seems OK on master but it feels a bit shaky. If
ProccessParallelMessages() throws an ERROR, the rest of the messages
won't be processed, but that's OK, because all the workers are part of
the same parallel context, and they will be shut down on error cleanup.
For parallel apply, ProcessParallelApplyMessage() assumes that throwing
an error will terminate the whole leader process, so it's also OK to not
process any remaining parallel apply messages.
There's one corner case in master already in that scenario (i.e. you
have parallel query workers and parallel apply workers and a PL/pgSQL
block that catches an error): If you receive an error from a parallel
apply worker, ProcessParallelApplyMessage() throws the ERROR:
ERROR: logical replication parallel apply worker exited due to error
DETAIL: The leader apply worker will now exit and terminate any other
parallel apply workers.
However, if that happens in the PL/pgSQL block, the exception handler
will catch that ERROR, abort just the subtransaction, and continue
running. I wonder if that should be FATAL? Or if we should do some other
more explicit cleanup, instead of relying on process exit?
- Heikki
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rafael Chacón | 2026-12-02 15:48:52 | Re: Table synchronization cannot resume after a subscriber crash |
| Previous Message | Greg Burd | 2026-12-02 15:18:27 | Re: nbtree: opt-in leaf key prefix compression |