Change the misleading local end_lsn for prepared transactions.
authorAmit Kapila <[email protected]>
Fri, 9 Aug 2024 04:53:57 +0000 (10:23 +0530)
committerAmit Kapila <[email protected]>
Fri, 9 Aug 2024 04:53:57 +0000 (10:23 +0530)
commit701cf1e3174d560a19c019f1085c73ef667acf2d
tree945b709362fd338bcac225a50a8aaf5f2e440693
parent4eb179e5bf7a5551ce3963d1563d6c9968c1a257
Change the misleading local end_lsn for prepared transactions.

The apply worker was using XactLastCommitEnd as local end_lsn for applying
prepare and rollback_prepare. The XactLastCommitEnd value is the end lsn
of the last commit applied before the prepare transaction which makes no
sense. This LSN is used to decide whether we can send the acknowledgment
of the corresponding remote LSN to the server.

It is okay not to set the local_end LSN with the actual WAL position for
the prepare because we always flush the prepare record. So, we can send
the acknowledgment of the remote_end LSN as soon as prepare is finished.

The current code is misleading but as such doesn't create any problem, so
decided not to backpatch.

Author: Hayato Kuroda
Reviewed-by: Shveta Malik, Amit Kapila
Discussion: https://postgr.es/m/TYAPR01MB5692FA4926754B91E9D7B5F0F5AA2@TYAPR01MB5692.jpnprd01.prod.outlook.com
src/backend/replication/logical/worker.c