Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions.
authorNoah Misch <[email protected]>
Sat, 30 Jan 2021 08:00:27 +0000 (00:00 -0800)
committerNoah Misch <[email protected]>
Sat, 30 Jan 2021 08:05:34 +0000 (00:05 -0800)
commit77a0e14f0b21d34c31c3eabaf249844607680fbe
treea655d4f04191ec1f8a77f76f073b4afd137e1392
parentd777e27c80f83e1177393641b99b1c7c4b19af17
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
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/lock.c
src/include/storage/lock.h
src/test/isolation/Makefile
src/test/isolation/README
src/test/isolation/expected/prepared-transactions-cic.out [new file with mode: 0644]
src/test/isolation/specs/prepared-transactions-cic.spec [new file with mode: 0644]