Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit eb5f4d6

Browse files
committed
Revert ill-fated patch to release exclusive lock early after vacuum
truncates a table. Introduces race condition, as shown by buildfarm failures.
1 parent 754838c commit eb5f4d6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 8 additions & 3 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.97 2007/09/20 17:56:31 tgl Exp $
39+
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.98 2007/09/20 21:43:27 tgl Exp $
4040
*
4141
*-------------------------------------------------------------------------
4242
*/
@@ -855,8 +855,13 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
855855
*/
856856
RelationTruncate(onerel, new_rel_pages);
857857

858-
/* Now we're OK to release the lock. */
859-
UnlockRelation(onerel, AccessExclusiveLock);
858+
/*
859+
* Note: once we have truncated, we *must* keep the exclusive lock
860+
* until commit. The sinval message that will be sent at commit
861+
* (as a result of vac_update_relstats()) must be received by other
862+
* backends, to cause them to reset their rd_targblock values, before
863+
* they can safely access the table again.
864+
*/
860865

861866
/*
862867
* Drop free-space info for removed blocks; these must not get entered

0 commit comments

Comments
 (0)