Fix an oversight in 3f28b2fcac.
authorAmit Kapila <akapila@postgresql.org>
Wed, 23 Apr 2025 05:22:36 +0000 (10:52 +0530)
committerAmit Kapila <akapila@postgresql.org>
Wed, 23 Apr 2025 05:22:36 +0000 (10:52 +0530)
commit05676d87e2e69a889abf75ce4f0c1bedde9ed71f
tree41d082a5d54d09e6fd65519748d71fc3f8707717
parent4b6331e0fd5779f31df640d6f5b08a03d8dfb829
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.the.mccoy@gmail.com>
Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Backpatch-through: 16, where it was introduced
Discussion: https://postgr.es/m/CALsgZNCGARa2mcYNVTSj9uoPcJo-tPuWUGECReKpNgTpo31_Pw@mail.gmail.com
src/backend/replication/logical/worker.c
src/test/subscription/t/100_bugs.pl