Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions.

Noah Misch <noah@leadboat.com>

Commit: 179775135b41a0640ec8b378b2699dca00d3a49a
Author: Noah Misch <noah@leadboat.com>
Date: 2021-01-30T08:02:11Z
Releases: 10.16
Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions.

In a cluster having used CREATE INDEX CONCURRENTLY while having enabled
prepared transactions, queries that use the resulting index can silently
fail to find rows.  Fix this for future CREATE INDEX CONCURRENTLY by
making it wait for prepared transactions like it waits for ordinary
transactions.  This expands the VirtualTransactionId structure domain to
admit prepared transactions.  It may be necessary to reindex to recover
from past occurrences.  Back-patch to 9.5 (all supported versions).

Andrey Borodin, reviewed (in earlier versions) by Tom Lane and Michael
Paquier.

Discussion: https://postgr.es/m/2E712143-97F7-4890-B470-4A35142ABC82@yandex-team.ru

Files

Discussion