Thread: pgsql: Correct predicate locking for DROP INDEX CONCURRENTLY.

pgsql: Correct predicate locking for DROP INDEX CONCURRENTLY.

From
Kevin Grittner
Date:
Correct predicate locking for DROP INDEX CONCURRENTLY.

For the non-concurrent case there is an AccessExclusiveLock lock
on both the index and the heap at a time during which no other
process is using either, before which the index is maintained and
used for scans, and after which the index is no longer used or
maintained.  Predicate locks can safely be moved from the index to
the related heap relation under the protection of these locks.
This was done prior to the introductin of DROP INDEX CONCURRENTLY
and continues to be done for non-concurrent index drops.

For concurrent index drops, the predicate locks must be moved when
there are no index scans in progress on that index and no more can
subsequently start, and before heap inserts stop maintaining the
index.  As long as these conditions are guaranteed when the
TransferPredicateLocksToHeapRelation() function is called,
stronger locks are not needed for correctness.

Kevin Grittner based on questions by Tom Lane in reviewing the
DROP INDEX CONCURRENTLY patch and in cooperation with Andres
Freund and Simon Riggs.

Back-patch of commit 4c9d0901f135d724a9f3cfa4140a5afd44b10f08

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/523ecaf40436588278701ace3c06dc80d2189068

Modified Files
--------------
src/backend/catalog/index.c |   28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)