pgsql: Don't choose an invalid index for REPLICA IDENTITY FULL lookups.

Поиск
Список
Период
Сортировка
Искать

pgsql: Don't choose an invalid index for REPLICA IDENTITY FULL lookups.

От:
Amit Kapila <akapila@postgresql.org>
Дата:
Вложения:
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 
Reviewed-by: Miłosz Bieniek 
Reviewed-by: Amit Kapila 
Reviewed-by: Shlok Kyal 
Reviewed-by: Vignesh C 
Reviewed-by: Ajin Cherian 
Discussion: https://postgr.es/m/CADzfLwWuubcbJBDRZ_J1SSqHDNjNmUYSAgf5y=17LxmP401xbw@mail.gmail.com
Backpatch-through: 16, where it was introduced

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b3272b49aac9a921d3cdafeb636742414fb33788

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(-)

FAQ