Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a10f0f

Browse files
committed
Release the exclusive lock on the table early after truncating it in lazy
vacuum, instead of waiting till commit.
1 parent f7379f5 commit 6a10f0f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
*
3838
* IDENTIFICATION
39-
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.92 2007/09/10 17:58:45 alvherre Exp $
39+
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.93 2007/09/10 21:40:03 alvherre Exp $
4040
*
4141
*-------------------------------------------------------------------------
4242
*/
@@ -802,6 +802,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
802802
*/
803803
RelationTruncate(onerel, new_rel_pages);
804804

805+
/* Now we're OK to release the lock. */
806+
UnlockRelation(onerel, AccessExclusiveLock);
807+
805808
/*
806809
* Drop free-space info for removed blocks; these must not get entered
807810
* into the FSM!
@@ -834,10 +837,6 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
834837
vacrelstats->rel_pages = new_rel_pages;
835838
vacrelstats->pages_removed = old_rel_pages - new_rel_pages;
836839

837-
/*
838-
* We keep the exclusive lock until commit (perhaps not necessary)?
839-
*/
840-
841840
ereport(elevel,
842841
(errmsg("\"%s\": truncated %u to %u pages",
843842
RelationGetRelationName(onerel),

0 commit comments

Comments
 (0)