mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions.
The purpose of commit 8a54e12a38
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
This commit is contained in:
@ -2462,6 +2462,13 @@ PrepareTransaction(void)
|
||||
/* Reset XactLastRecEnd until the next transaction writes something */
|
||||
XactLastRecEnd = 0;
|
||||
|
||||
/*
|
||||
* Transfer our locks to a dummy PGPROC. This has to be done before
|
||||
* ProcArrayClearTransaction(). Otherwise, a GetLockConflicts() would
|
||||
* conclude "xact already committed or aborted" for our locks.
|
||||
*/
|
||||
PostPrepare_Locks(xid);
|
||||
|
||||
/*
|
||||
* Let others know about no transaction in progress by me. This has to be
|
||||
* done *after* the prepared transaction has been marked valid, else
|
||||
@ -2501,7 +2508,6 @@ PrepareTransaction(void)
|
||||
|
||||
PostPrepare_MultiXact(xid);
|
||||
|
||||
PostPrepare_Locks(xid);
|
||||
PostPrepare_PredicateLocks(xid);
|
||||
|
||||
ResourceOwnerRelease(TopTransactionResourceOwner,
|
||||
|
Reference in New Issue
Block a user