pgsql: Don't advance origin during apply failure.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't advance origin during apply failure.
Date: 2025-12-24 04:47:03
Message-ID: E1vYGm6-002MTG-0I@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't advance origin during apply failure.

The logical replication parallel apply worker could incorrectly advance
the origin progress during an error or failed apply. This behavior risks
transaction loss because such transactions will not be resent by the
server.

Commit 3f28b2fcac addressed a similar issue for both the apply worker and
the table sync worker by registering a before_shmem_exit callback to reset
origin information. This prevents the worker from advancing the origin
during transaction abortion on shutdown. This patch applies the same fix
to the parallel apply worker, ensuring consistent behavior across all
worker types.

As with 3f28b2fcac, we are backpatching through version 16, since parallel
apply mode was introduced there and the issue only occurs when changes are
applied before the transaction end record (COMMIT or ABORT) is received.

Author: Hou Zhijie <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Backpatch-through: 16
Discussion: https://postgr.es/m/TY4PR01MB169078771FB31B395AB496A6B94B4A@TY4PR01MB16907.jpnprd01.prod.outlook.com
Discussion: https://postgr.es/m/TYAPR01MB5692FAC23BE40C69DA8ED4AFF5B92@TYAPR01MB5692.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1528b0d899d65e0b01120f7d06c23256d390e4fe

Modified Files
--------------
src/backend/replication/logical/worker.c | 30 +++++++++--------
src/test/subscription/t/023_twophase_stream.pl | 45 ++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-12-24 08:10:42 pgsql: Improve comment in pgstatfuncs.c
Previous Message Tom Lane 2025-12-24 02:39:06 pgsql: Fix another case of indirectly casting away const.