]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions.
authorNoah Misch <noah@leadboat.com>
Sun, 24 Oct 2021 01:36:38 +0000 (18:36 -0700)
committerNoah Misch <noah@leadboat.com>
Sun, 24 Oct 2021 01:36:43 +0000 (18:36 -0700)
commit5184932432b414478edebd74d13d4d16c7ca070c
treef58a3082f8fb3d08b50a7b26b3934acd3b963a8a
parente428699cb3be0a7abbd5a83bfa5ec3e26c7fea84
Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions.

The purpose of commit 8a54e12a38d1545d249f1402f66c8cde2837d97c was to
fix this, and it sufficed when the PREPARE TRANSACTION completed before
the CIC looked for lock conflicts.  Otherwise, things still broke.  As
before, in a cluster having used CIC while having enabled prepared
transactions, queries that use the resulting index can silently fail to
find rows.  It may be necessary to reindex to recover from past
occurrences; REINDEX CONCURRENTLY suffices.  Fix this for future index
builds by making CIC wait for arbitrarily-recent prepared transactions
and for ordinary transactions that may yet PREPARE TRANSACTION.  As part
of that, have PREPARE TRANSACTION transfer locks to its dummy PGPROC
before it calls ProcArrayClearTransaction().  Back-patch to 9.6 (all
supported versions).

Andrey Borodin, reviewed (in earlier versions) by Andres Freund.

Discussion: https://postgr.es/m/01824242-AA92-4FE9-9BA7-AEBAFFEA3D0C@yandex-team.ru
src/backend/access/transam/twophase.c
src/backend/access/transam/xact.c
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/lock.c
src/backend/utils/cache/inval.c
src/bin/pgbench/t/023_cic_2pc.pl [new file with mode: 0644]
src/include/access/twophase.h
src/include/storage/lock.h
src/test/perl/PostgresNode.pm