pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix logical replication with lossy identity indexes. 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix logical replication with lossy identity indexes. @ 2026-10-21 03:27 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Amit Kapila @ 2026-10-21 03:27 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix logical replication with lossy identity indexes. A GiST index on a multirange stores only its bounding range, so different multiranges can produce the same index key. However, RelationFindReplTupleByIndex() and RelationFindDeletedTupleInfoByIndex() assume that matches through a primary key or replica identity index are exact and skip the equality check. This can cause updates or deletes to target the wrong row, and conflict detection to report update_deleted instead of update_missing. Fix this by rechecking candidates when the index scan sets xs_recheck. Compare only the index key columns, using the scan keys' equality operators and collations to match the index's notion of key equality. Backpatch to 18, where WITHOUT OVERLAPS was introduced. The change to RelationFindDeletedTupleInfoByIndex() applies only to 19 and later, where update_deleted conflict detection was added. Reported-by: Andres Freund <andres@anarazel.de> Author: Paul A. Jungwirth <pj@illuminatedcomputing.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: kedar anavardekar <kedar.anavardekar@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/kcyaok346iwocfdourf2oojgtz7ggxmh2ugis7qqhggs4qfzc2@cu6pkox4rfwp Discussion: https://postgr.es/m/e5nb5jbus2oa3pffmlo7pdvdckmchd54tqld4k3n6huyg5xxqn@7rounyvufjx6 Discussion: https://postgr.es/m/CA+renyWzTBC4GetPzJM1KqrejrmOWcGnn2NaA7tpee17HFxRPw@mail.gmail.com Backpatch-through: 18 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/3cde90ecc5f85e7c6cb9fba29d473b2f6dd40ee1 Modified Files -------------- src/backend/executor/execReplication.c | 66 ++++++++++++++++++++++-- src/test/subscription/t/034_temporal.pl | 71 ++++++++++++++++++++++++++ src/test/subscription/t/035_conflicts.pl | 86 ++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix logical replication with lossy identity indexes. @ 2026-10-21 03:27 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Amit Kapila @ 2026-10-21 03:27 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix logical replication with lossy identity indexes. A GiST index on a multirange stores only its bounding range, so different multiranges can produce the same index key. However, RelationFindReplTupleByIndex() and RelationFindDeletedTupleInfoByIndex() assume that matches through a primary key or replica identity index are exact and skip the equality check. This can cause updates or deletes to target the wrong row, and conflict detection to report update_deleted instead of update_missing. Fix this by rechecking candidates when the index scan sets xs_recheck. Compare only the index key columns, using the scan keys' equality operators and collations to match the index's notion of key equality. Backpatch to 18, where WITHOUT OVERLAPS was introduced. The change to RelationFindDeletedTupleInfoByIndex() applies only to 19 and later, where update_deleted conflict detection was added. Reported-by: Andres Freund <andres@anarazel.de> Author: Paul A. Jungwirth <pj@illuminatedcomputing.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: kedar anavardekar <kedar.anavardekar@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/kcyaok346iwocfdourf2oojgtz7ggxmh2ugis7qqhggs4qfzc2@cu6pkox4rfwp Discussion: https://postgr.es/m/e5nb5jbus2oa3pffmlo7pdvdckmchd54tqld4k3n6huyg5xxqn@7rounyvufjx6 Discussion: https://postgr.es/m/CA+renyWzTBC4GetPzJM1KqrejrmOWcGnn2NaA7tpee17HFxRPw@mail.gmail.com Backpatch-through: 18 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/48b43081e550f9e4b04e1184ed6d3fed4f850691 Modified Files -------------- src/backend/executor/execReplication.c | 66 ++++++++++++++++++++++-- src/test/subscription/t/034_temporal.pl | 71 ++++++++++++++++++++++++++ src/test/subscription/t/035_conflicts.pl | 86 ++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix logical replication with lossy identity indexes. @ 2026-10-21 03:27 Amit Kapila <akapila@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Amit Kapila @ 2026-10-21 03:27 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix logical replication with lossy identity indexes. A GiST index on a multirange stores only its bounding range, so different multiranges can produce the same index key. However, RelationFindReplTupleByIndex() and RelationFindDeletedTupleInfoByIndex() assume that matches through a primary key or replica identity index are exact and skip the equality check. This can cause updates or deletes to target the wrong row, and conflict detection to report update_deleted instead of update_missing. Fix this by rechecking candidates when the index scan sets xs_recheck. Compare only the index key columns, using the scan keys' equality operators and collations to match the index's notion of key equality. Backpatch to 18, where WITHOUT OVERLAPS was introduced. The change to RelationFindDeletedTupleInfoByIndex() applies only to 19 and later, where update_deleted conflict detection was added. Reported-by: Andres Freund <andres@anarazel.de> Author: Paul A. Jungwirth <pj@illuminatedcomputing.com> Author: Zhijie Hou <houzhijie22@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: kedar anavardekar <kedar.anavardekar@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/kcyaok346iwocfdourf2oojgtz7ggxmh2ugis7qqhggs4qfzc2@cu6pkox4rfwp Discussion: https://postgr.es/m/e5nb5jbus2oa3pffmlo7pdvdckmchd54tqld4k3n6huyg5xxqn@7rounyvufjx6 Discussion: https://postgr.es/m/CA+renyWzTBC4GetPzJM1KqrejrmOWcGnn2NaA7tpee17HFxRPw@mail.gmail.com Backpatch-through: 18 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/23fffd382ca06690fdce91bc4819a57017cb1dda Modified Files -------------- src/backend/executor/execReplication.c | 60 ++++++++++++++++++++++++++-- src/test/subscription/t/034_temporal.pl | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-10-21 03:27 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-10-21 03:27 pgsql: Fix logical replication with lossy identity indexes. Amit Kapila <akapila@postgresql.org> 2026-10-21 03:27 pgsql: Fix logical replication with lossy identity indexes. Amit Kapila <akapila@postgresql.org> 2026-10-21 03:27 pgsql: Fix logical replication with lossy identity indexes. Amit Kapila <akapila@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox