From 27336e4f7a2dddfcd31fbf68e98ca9bb0abd0165 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 16 May 2001 22:35:12 +0000 Subject: Repair race condition introduced into heap_update() in 7.1 --- PageGetFreeSpace() was being called while not holding the buffer lock, which not only could yield a garbage answer, but even if it's the right answer there might be less space available after we reacquire the buffer lock. Also repair potential deadlock introduced by my recent performance improvement in RelationGetBufferForTuple(): it was possible for two heap_updates to try to lock two buffers in opposite orders. The fix creates a global rule that buffers of a single heap relation should be locked in decreasing block number order. Currently, this only applies to heap_update; VACUUM can get away with ignoring the rule since it holds exclusive lock on the whole relation anyway. However, if we try to implement a VACUUM that can run in parallel with other transactions, VACUUM will also have to obey the lock order rule. --- src/include/access/hio.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/include/access/hio.h') diff --git a/src/include/access/hio.h b/src/include/access/hio.h index 4147645134a..8c50a128a20 100644 --- a/src/include/access/hio.h +++ b/src/include/access/hio.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hio.h,v 1.17 2001/01/24 19:43:19 momjian Exp $ + * $Id: hio.h,v 1.18 2001/05/16 22:35:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,6 +18,7 @@ extern void RelationPutHeapTuple(Relation relation, Buffer buffer, HeapTuple tuple); -extern Buffer RelationGetBufferForTuple(Relation relation, Size len); +extern Buffer RelationGetBufferForTuple(Relation relation, Size len, + BlockNumber minblocknum); #endif /* HIO_H */ -- cgit v1.2.3