Skip site navigation (1) Skip section navigation (2)

Re: pgstattuple locking fix

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: pgstattuple locking fix
Date: 2007-10-22 09:42:44
Message-ID: 20071022183548.6064.ITAGAKI.TAKAHIRO@oss.ntt.co.jp (view raw or flat)
Thread:
Lists: pgsql-patches
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> > Here is a trivial fix of locking issue in pgstattuple().
> 
> Hmm, is this really a bug, and if so how far back does it go?
> I'm thinking that having a pin on the buffer should be enough to
> call PageGetHeapFreeSpace.

Hmm... we might use pd_upper and pd_lower at different times,
but the error is ok for pgstattuple purpose.
(It might be dangerous for tuple insertion, though.)
Inconsistent usage of locks is confusable -- remove them, please.

Index: contrib/pgstattuple/pgstattuple.c
===================================================================
--- contrib/pgstattuple/pgstattuple.c	(HEAD)
+++ contrib/pgstattuple/pgstattuple.c	(working copy)
@@ -289,9 +289,7 @@
 		while (block <= tupblock)
 		{
 			buffer = ReadBuffer(rel, block);
-			LockBuffer(buffer, BUFFER_LOCK_SHARE);
 			stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
-			LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
 			ReleaseBuffer(buffer);
 			block++;
 		}

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center



In response to

Responses

pgsql-patches by date

Next:From: Heikki LinnakangasDate: 2007-10-22 09:54:10
Subject: Re: pgstattuple locking fix
Previous:From: Gokulakannan SomasundaramDate: 2007-10-22 06:50:21
Subject: Re: Including Snapshot Info with Indexes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group