RE: Disabled logical replication origin session causes primary key errors

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Amit Kapila' <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Shawn McCoy <shawn(dot)the(dot)mccoy(at)gmail(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>, "drewwcallahan(at)gmail(dot)com" <drewwcallahan(at)gmail(dot)com>, "scott(at)meads(dot)us" <scott(at)meads(dot)us>
Subject: RE: Disabled logical replication origin session causes primary key errors
Date: 2025-04-21 10:08:18
Message-ID: OSCPR01MB14966B223A32363FF8D253D0EF5B82@OSCPR01MB14966.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Dear members,

Thanks for reporting the issue.

> Right. We have wrongly assumed in that commit that the apply worker
> will exit after an ERROR, but as shown by this case, the ERROR could
> be silently handled. So, +1, for moving replication origin reset to
> PG_CATCH in start_apply.

I was an author of original commit, so let me take initiative. When I was working
for 3f28b2fcac, I could not find path which ERROR is reported but worker can
survive so that I added replorigin_reset() in apply_error_callback(). The reported
case, however, the exception could be raised but the insert itself is committed.
In this case worker can continue working.

Attached patches have proposed changes. I did 1) meson test, 2) workloads provided
in [1], and 3) manual tests done in original thread [2], and all of them could be
passed. The version is 2 because of the self-reviewing.

One note is that geterrlevel() is removed for HEAD patch but retained for PG16/PG17.
The function is exported, and APIs cannot be changed in back branches.

How do you feel?

[1]: https://stream.boxwatch.ru/message-id/flat/CALsgZNCGARa2mcYNVTSj9uoPcJo-tPuWUGECReKpNgTpo31_Pw%40mail.gmail.com
[2]: https://stream.boxwatch.ru/message-id/CAJpy0uAa3M9sC3GWTUA%2BYPTnYxEcorFt_7g6rXz05jNcAGdjgQ%40mail.gmail.com

Best regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment Content-Type Size
v2-HEAD-0001-Fix-oversight-3f28b2f.patch application/octet-stream 3.7 KB
v2-PG16-PG17-0001-Fix-oversight-3f28b2f.patch application/octet-stream 2.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kirill Reshke 2025-04-21 10:56:39 Command order bug in pg_dump
Previous Message Tomas Vondra 2025-04-21 09:41:19 Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2