pgsql: Remove the redundant remote_final_lsn variable from the apply wo

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove the redundant remote_final_lsn variable from the apply wo
Date: 2026-08-26 05:28:46
Message-ID: E1wz6Bp-000000029U6-1bT7@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove the redundant remote_final_lsn variable from the apply worker.

The apply worker tracked the final LSN of the remote transaction being
applied in a separate global variable remote_final_lsn, even though
apply_error_callback_arg already tracked the same transaction's xid and
finish LSN for error context reporting, and both were updated together
at the same places.

Rename ApplyErrorCallbackArg to ApplyRemoteCtx and treat its
remote_xid/finish_lsn pair as the generic descriptor of the remote
transaction currently being applied, replacing all uses of
remote_final_lsn so the redundant global can be removed.

There is no behavior change.

Recording the remote transaction being applied in a single place should
also help the proposed conflict log table patch, which needs the same
information when logging a conflict.

Author: Zhijie Hou <houzj(dot)fnst(at)fujitsu(dot)com>
Author: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Reviewed-by: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Reviewed-by: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Reviewed-by: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Discussion: https://postgr.es/m/TY4PR01MB177186ED4D38C5356294CC51C94A42@TY4PR01MB17718.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2f4df67f5d00836979bc72bf6113adb45aff48df

Modified Files
--------------
.../replication/logical/applyparallelworker.c | 5 +-
src/backend/replication/logical/worker.c | 243 ++++++++++++---------
src/tools/pgindent/typedefs.list | 2 +-
3 files changed, 141 insertions(+), 109 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2026-08-26 09:24:04 pgsql: Skip relations dropped concurrently in GetSubscriptionRelations(
Previous Message Fujii Masao 2026-08-26 01:38:18 pgsql: doc: Update REPACK-related table rewrite documentation