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

RE: [HACKERS] Re: possible row locking bug in 7.0.3 & 7.1

From: "Mikheev, Vadim" <vmikheev(at)SECTORBASE(dot)COM>
To: "'Hiroshi Inoue'" <Inoue(at)tpf(dot)co(dot)jp>
Cc: Philip Warner <pjw(at)rhyme(dot)com(dot)au>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: RE: [HACKERS] Re: possible row locking bug in 7.0.3 & 7.1
Date: 2001-03-30 18:54:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-sql
> > > I doubt if it's a bug of SELECT. Well what
> > > 'concurrent UPDATE then SELECT FOR UPDATE +
> > > SELECT' return ?
> > 
> > I'm going to add additional check to heapgettup and
> > heap_fetch:
> SELECT seems to be able to return a different result
> from that of preceding SELECT FOR UPDATE even after
> applying your change.

Oh, you're right. Well, if we really want that SELECT
returns the same result as SELECT FOR UPDATE *in functions*
(out of functions results are already same) then we have to
add some modifications to fix proposed:

1. If newer version of visible tuple T is marked for update by
us *before* query began then do not return T.

2. If tuple T1 is *not visible* because of it was inserted by
concurrent committed TX then check if it's marked for update
by current TX *before* query began and return *this* tuple
version if yes.

This will be in accordance with standard which requires
us return committed (whenever) rows in READ COMMITTED mode.
In fact, in this mode our SELECTs provide higher isolation
than required by standard returning rows committed *before*
query began. Why? Because of SELECT doesn't lock rows and
the same row may be visited by SELECT in join queries
many times - so we have to be protected against concurrent
updates. SELECT FOR UPDATE protects us BUT if query itself
calls some functions which updates queried table then currently
we may lose information that tuple was marked for update before
query began - so updating tuple inserted by concurrent committed
TX and marked for update by us we would have to save its t_cmax
in t_cmin (and either add new flag to t_infomask or don't turn

This is not what I would like to do in 7.1

> SELECT doesn't seem guilty but the result is far 
> from intuitive.

I think that SELECT is guilty. At least returning two versions
of the same row! (One that could be fixed easy).


pgsql-hackers by date

Next:From: Jan T. KimDate: 2001-03-30 19:20:49
Subject: Re: [ADMIN] User administration tool
Previous:From: Bruce MomjianDate: 2001-03-30 18:44:49
Subject: Re: RC2 schedualed for Tomorrow evening ...

pgsql-sql by date

Next:From: Tim PerdueDate: 2001-03-30 19:32:53
Subject: Vacuum Error
Previous:From: Josh BerkusDate: 2001-03-30 17:37:31
Subject: Re: Possible 7.1RC1 bug

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