agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Use WAL insert position for conflict detection. 2+ messages / 1 participants [nested] [flat]
* pgsql: Use WAL insert position for conflict detection. @ 2026-09-03 08:49 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Amit Kapila @ 2026-09-03 08:49 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Use WAL insert position for conflict detection. The retain_dead_tuples feature waits for concurrent transactions to be applied before advancing conflict_detection_slot.xmin. It gets the WAL write position from the publisher and waits until the apply remote position passes it. This ensures that dead tuples, commit timestamps, and origins needed for conflict detection (update_deleted, update_origin_differs, and delete_origin_differs) are retained while those transactions are applied. However, with asynchronous commit enabled on the publisher, a committed transaction may not have updated the WAL write position yet. As a result, the reported WAL position can lag behind the latest committed transaction. This can cause conflict_detection_slot.xmin to advance prematurely, allowing dead tuples needed for conflict detection to be removed before subsequent asynchronously committed transactions are applied. Report the end of the last inserted WAL record instead. A transaction inserts its commit record before it is marked committed, so the insert position cannot be behind a transaction that has already committed. Transactions that have entered the commit phase but have not yet inserted their commit record are still accounted for by the in-commit transaction ID reported in the same message. In addition to above, add missing trailing period to update_deleted conflict detail messages which are added for the same feature. Reported-by: Nisha Moond <nisha.moond412@gmail.com> Author: Zhijie Hou <houzj.fnst@fujitsu.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/TY4PR01MB177182F547A62FC2666EC04EC94B72@TY4PR01MB17718.jpnprd01.prod.outlook.com Backpatch-through: 19, where it was introduced Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/5f3a49abf7ff7bb4a9eba7101eb8e8021960074f Modified Files -------------- src/backend/replication/logical/conflict.c | 8 ++++---- src/backend/replication/logical/worker.c | 6 +++--- src/backend/replication/walsender.c | 25 ++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Use WAL insert position for conflict detection. @ 2026-09-03 08:49 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Amit Kapila @ 2026-09-03 08:49 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Use WAL insert position for conflict detection. The retain_dead_tuples feature waits for concurrent transactions to be applied before advancing conflict_detection_slot.xmin. It gets the WAL write position from the publisher and waits until the apply remote position passes it. This ensures that dead tuples, commit timestamps, and origins needed for conflict detection (update_deleted, update_origin_differs, and delete_origin_differs) are retained while those transactions are applied. However, with asynchronous commit enabled on the publisher, a committed transaction may not have updated the WAL write position yet. As a result, the reported WAL position can lag behind the latest committed transaction. This can cause conflict_detection_slot.xmin to advance prematurely, allowing dead tuples needed for conflict detection to be removed before subsequent asynchronously committed transactions are applied. Report the end of the last inserted WAL record instead. A transaction inserts its commit record before it is marked committed, so the insert position cannot be behind a transaction that has already committed. Transactions that have entered the commit phase but have not yet inserted their commit record are still accounted for by the in-commit transaction ID reported in the same message. In addition to above, add missing trailing period to update_deleted conflict detail messages which are added for the same feature. Reported-by: Nisha Moond <nisha.moond412@gmail.com> Author: Zhijie Hou <houzj.fnst@fujitsu.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/TY4PR01MB177182F547A62FC2666EC04EC94B72@TY4PR01MB17718.jpnprd01.prod.outlook.com Backpatch-through: 19, where it was introduced Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/08b016edd568cd154af3c23b8b347a8d1036498d Modified Files -------------- src/backend/replication/logical/conflict.c | 8 ++++---- src/backend/replication/logical/worker.c | 6 +++--- src/backend/replication/walsender.c | 25 ++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-09-03 08:49 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-09-03 08:49 pgsql: Use WAL insert position for conflict detection. Amit Kapila <akapila@postgresql.org> 2026-09-03 08:49 pgsql: Use WAL insert position for conflict detection. Amit Kapila <akapila@postgresql.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox