Re: pgstattuple locking fix - Mailing list pgsql-patches

From Heikki Linnakangas
Subject Re: pgstattuple locking fix
Date
Msg-id 471C7342.2040102@enterprisedb.com
Whole thread Raw
In response to Re: pgstattuple locking fix  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: pgstattuple locking fix  ("Heikki Linnakangas" <heikki@enterprisedb.com>)
Re: pgstattuple locking fix  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
ITAGAKI Takahiro wrote:
> 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.

No I think the original patch was right. You can indeed read
inconsistent values for pd_upper and pd_lower, though the window is very
small. But a bigger issue is that in 8.3 PageGetHeapFreeSpace counts the
used line pointers to see if MaxHeapTuplesPerPage has been reached, and
I'm not convinced you can do that safely without holding a lock.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

pgsql-patches by date:

Previous
From: ITAGAKI Takahiro
Date:
Subject: Re: pgstattuple locking fix
Next
From: "Heikki Linnakangas"
Date:
Subject: Re: pgstattuple locking fix