Re: pgstattuple locking fix - Mailing list pgsql-patches

From ITAGAKI Takahiro
Subject Re: pgstattuple locking fix
Date
Msg-id 20071022183548.6064.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Whole thread Raw
In response to Re: pgstattuple locking fix  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgstattuple locking fix
List pgsql-patches
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.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



pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgstattuple locking fix
Next
From: "Heikki Linnakangas"
Date:
Subject: Re: pgstattuple locking fix