Re: Buffer access rules, and a probable bug

From: ncm(at)zembu(dot)com (Nathan Myers)
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Buffer access rules, and a probable bug
Date: 2001-07-03 22:59:34
Message-ID: 20010703155934.L1466@store.zembu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 03, 2001 at 05:11:46PM -0400, Tom Lane wrote:
> ncm(at)zembu(dot)com (Nathan Myers) writes:
> > On Mon, Jul 02, 2001 at 09:40:25PM -0400, Tom Lane wrote:
> >> 4. It is considered OK to update tuple commit status bits (ie, OR the
> >> values HEAP_XMIN_COMMITTED, HEAP_XMIN_INVALID, HEAP_XMAX_COMMITTED, or
> >> HEAP_XMAX_INVALID into t_infomask) while holding only a shared lock and
> >> pin on a buffer. This is OK because another backend looking at the tuple
> >> at about the same time would OR the same bits into the field, so there
> >> is little or no risk of conflicting update; what's more, if there did
> >> manage to be a conflict it would merely mean that one bit-update would
> >> be lost and need to be done again later.
>
> > Without looking at the code, this seems mad. Are you sure?
>
> Yes. Those status bits aren't ground truth, only hints. They cache the
> results of looking up transaction status in pg_log; if they get dropped,
> the only consequence is the next visitor to the tuple has to do the
> lookup over again.
>
> Changing any other bits in t_infomask requires exclusive lock, however.

Hmm, look:

A B

1 load t_infomask

2 or XMIN_INVALID

3 lock

4 load t_infomask

5 or MOVED_IN

6 store t_infomask

7 unlock

8 store t_infomask

Here, backend B is a good citizen and locks while it makes its change.
Backend A only means to touch the "hint" bits, but it ends up clobbering
the MOVED_IN bit too.

Also, as hints, would it be Bad(tm) if an attempt to clear one failed?
That seems possible as well.

Nathan Myers
ncm(at)zembu(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2001-07-03 23:30:16 Re: stuck spin lock with many concurrent users
Previous Message Bruce Momjian 2001-07-03 22:44:29 Re: [OT] Any major users of postgresql?