• Kevin Grittner's avatar
    Correct predicate locking for DROP INDEX CONCURRENTLY. · 4c9d0901
    Kevin Grittner authored
    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.
    4c9d0901
index.c 106 KB