Thread: pgsql: Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transact

pgsql: Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transact

From
Noah Misch
Date:
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

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/77a0e14f0b21d34c31c3eabaf249844607680fbe

Modified Files
--------------
src/backend/storage/lmgr/lmgr.c                    |  3 +-
src/backend/storage/lmgr/lock.c                    | 43 +++++++++++++---------
src/include/storage/lock.h                         | 18 ++++-----
src/test/isolation/Makefile                        | 11 +++---
src/test/isolation/README                          |  8 ++--
.../expected/prepared-transactions-cic.out         | 18 +++++++++
.../isolation/specs/prepared-transactions-cic.spec | 37 +++++++++++++++++++
7 files changed, 100 insertions(+), 38 deletions(-)