pgsql: Fix an oversight in 3f28b2fcac.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix an oversight in 3f28b2fcac.
Date: 2025-04-23 05:40:45
Message-ID: E1u7Sqj-001MOQ-0v@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix an oversight in 3f28b2fcac.

Commit 3f28b2fcac tried to ensure that the replication origin shouldn't be
advanced in case of an ERROR in the apply worker, so that it can request
the same data again after restart. However, it is possible that an ERROR
was caught and handled by a (say PL/pgSQL) function, and the apply worker
continues to apply further changes, in which case, we shouldn't reset the
replication origin.

Ensure to reset the origin only when the apply worker exits after an
ERROR.

Commit 3f28b2fcac added new function geterrlevel, which we removed in HEAD
as part of this commit, but kept it in backbranches to avoid breaking any
applications. A separate case can be made to have such a function even for
HEAD.

Reported-by: Shawn McCoy <shawn(dot)the(dot)mccoy(at)gmail(dot)com>
Author: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Backpatch-through: 16, where it was introduced
Discussion: https://postgr.es/m/CALsgZNCGARa2mcYNVTSj9uoPcJo-tPuWUGECReKpNgTpo31_Pw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0e091ce409e06cd89baf81306cc92c496d8ba58d

Modified Files
--------------
src/backend/replication/logical/worker.c | 21 +++++----
src/backend/utils/error/elog.c | 17 -------
src/include/utils/elog.h | 1 -
src/test/subscription/t/100_bugs.pl | 77 ++++++++++++++++++++++++++++++++
4 files changed, 87 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-04-23 06:34:30 pgsql: psql: Rework TAP routine psql_fails_like() to define WAL sender
Previous Message Michael Paquier 2025-04-23 04:55:21 pgsql: Remove assertion based on pending_since in pgstat_report_stat()