Re: A note about hash-based catcache invalidations

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: A note about hash-based catcache invalidations
Date: 2011-08-17 17:25:16
Message-ID: CA+TgmoZaOqgaydYiwYexB-FZ0TBkOHUug8mZDq8ZgKY+OjRreQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 17, 2011 at 1:10 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> BTW, while we're thinking about this ...
>
> The plpython patch Jan just submitted reminds me that several of the PLs
> detect whether they have obsolete cached data by noting whether the
> tuple's xmin *and* TID are the same as previously seen.
>
> Unlike depending on TID alone, I think this is probably safe.  It can
> obviously give a false positive (thinks tuple changed when it didn't)
> after a catalog VACUUM FULL; but an error in that direction is safe.
> What would be problematic is a false negative (failure to notice a
> real change), and I think the inclusion of the xmin in the test protects
> us against that.  An example scenario is:
>
> 1. We cache the data, saving xmin X1 and TID T1.
>
> 2. VACUUM FULL moves the tuple to TID T2.
>
> 3. Somebody else updates the tuple, by chance moving it right back to
> T1.  But they will assign a new xmin X2, so we will know it changed.
>
> Can anyone think of a situation this does not cover?

What about this:

1. We cache the data, saving xmin X1 and TID T1.

2. VACUUM FULL moves the tuple to TID T2 but stores some other tuple in TID T1.

3. If the tuple that is now at TID T1 happens to have xmin = X1, we're
in trouble.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Byrne 2011-08-17 17:25:56 Re: rc1 or beta4?
Previous Message Tom Lane 2011-08-17 17:20:32 Re: PATCH: Compiling PostgreSQL using ActiveState Python 3.2