Hello,

When the remote relation has REPLICA IDENTITY FULL and the local one
has no primary key or replica identity, the apply worker looks for any
index it can search by.
FindUsableIndexForReplicaIdentityFull() walks RelationGetIndexList()
and takes the first index of a suitable shape without checking if it
is valid.
That list omits only indexes that are not indislive, so the leftover
from a failed CREATE INDEX CONCURRENTLY is eligible -- and such an
index need not contain every row.

A failed CIC validation leaves an index that scans cleanly but lacks
exactly the rows validation would have added. Consequently, updates
and deletes for those rows are dropped as update_missing conflicts and
the subscriber quietly diverges.

A failed build leaves an index that is empty down to the metapage,
which parks the subscription in a permanent error:
ERROR:  could not read blocks 0..0 in file "base/5/16433": read only 0
of 8192 bytes

The fix and a reproducer are in the attachments.

Affects 16 and up, from 89e46da5e51.

Regards,
Mikhail Nikalayeu

Attachment: v1-0001-Don-t-choose-an-invalid-index-for-REPLICA-IDENTIT.patch
Description: Binary data

Reply via email to