Fix CREATE INDEX CONCURRENTLY for simultaneous prepared transactions.
authorNoah Misch <noah@leadboat.com>
Sat, 30 Jan 2021 08:00:27 +0000 (00:00 -0800)
committerNoah Misch <noah@leadboat.com>
Sat, 30 Jan 2021 08:01:56 +0000 (00:01 -0800)
commitbe843ce29737ee4752fedabe07a75cf9db1e969f
treecee7ebddbda9ed73b58ed370d48a22f27cdf416b
parentbd6366129b1b97769c5293da1ec7f112cc68a444
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]