| From: | Amit Kapila <akapila(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Don't choose an invalid index for REPLICA IDENTITY FULL lookups. |
| Date: | 2026-08-27 04:50:12 |
| Message-ID: | E1wzS42-00000002IDR-3vKH@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Don't choose an invalid index for REPLICA IDENTITY FULL lookups.
For a REPLICA IDENTITY FULL remote relation whose local counterpart has
no primary key or replica identity, FindUsableIndexForReplicaIdentityFull()
chooses the first index of a suitable shape from RelationGetIndexList().
That list excludes only indexes that are not indislive, so an invalid
index left behind by a failed CREATE INDEX CONCURRENTLY can be selected.
Such an index need not contain every row. Consequently, changes for rows
that it fails to find can be silently dropped as missing-tuple conflicts.
If the index contains no rows at all, the scan can instead error out and
cause the apply worker to exit.
Skip invalid indexes, as the planner does.
Author: Mikhail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>
Reviewed-by: Miłosz Bieniek <bieniek(dot)milosz(at)proton(dot)me>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Reviewed-by: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Reviewed-by: Vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Ajin Cherian <itsajin(at)gmail(dot)com>
Discussion: https://postgr.es/m/CADzfLwWuubcbJBDRZ_J1SSqHDNjNmUYSAgf5y=17LxmP401xbw@mail.gmail.com
Backpatch-through: 16, where it was introduced
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/92c0182141cf6355f5ca38b282531aca64068d4e
Modified Files
--------------
src/backend/replication/logical/relation.c | 16 +++++-
src/test/subscription/t/032_subscribe_use_index.pl | 59 ++++++++++++++++++++++
2 files changed, 74 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Korotkov | 2026-08-27 08:14:55 | pgsql: Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) comm |
| Previous Message | Amit Kapila | 2026-08-27 04:50:11 | pgsql: Don't choose an invalid index for REPLICA IDENTITY FULL lookups. |