]> granicus.if.org Git - postgresql/commit
Correct predicate locking for DROP INDEX CONCURRENTLY.
authorKevin Grittner <kgrittn@postgresql.org>
Sun, 21 Oct 2012 21:35:42 +0000 (16:35 -0500)
committerKevin Grittner <kgrittn@postgresql.org>
Sun, 21 Oct 2012 21:35:42 +0000 (16:35 -0500)
commit4c9d0901f135d724a9f3cfa4140a5afd44b10f08
treefafd9f922ed7f315e77c21162abd8e9bdc325d8c
parentedef20f6e1e7a02c65163f1054ce71db4d719aad
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.
src/backend/catalog/index.c