Release the exclusive lock on the table early after truncating it in lazy
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 10 Sep 2007 21:40:03 +0000 (21:40 +0000)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 10 Sep 2007 21:40:03 +0000 (21:40 +0000)
vacuum, instead of waiting till commit.

src/backend/commands/vacuumlazy.c

index 5545796e97dcf36cd0e736092fdc3332ee02d03b..fc9497b4732fc7466a7db4d1f8d8b6e936329b1b 100644 (file)
@@ -802,6 +802,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
         */
        RelationTruncate(onerel, new_rel_pages);
 
+       /* Now we're OK to release the lock. */
+       UnlockRelation(onerel, AccessExclusiveLock);
+
        /*
         * Drop free-space info for removed blocks; these must not get entered
         * into the FSM!
@@ -834,10 +837,6 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
        vacrelstats->rel_pages = new_rel_pages;
        vacrelstats->pages_removed = old_rel_pages - new_rel_pages;
 
-       /*
-        * We keep the exclusive lock until commit (perhaps not necessary)?
-        */
-
        ereport(elevel,
                        (errmsg("\"%s\": truncated %u to %u pages",
                                        RelationGetRelationName(onerel),