Re: BUG #10748: xmax is not resetting properly with FOR UPDATE

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pinker(at)onet(dot)eu, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #10748: xmax is not resetting properly with FOR UPDATE
Date: 2014-07-29 15:03:15
Message-ID: 20140729150315.GE2791@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jun 24, 2014 at 05:15:25PM +0200, Andres Freund wrote:
> Hi,
>
> On 2014-06-24 14:29:26 +0000, pinker(at)onet(dot)eu wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference: 10748
> > Logged by: Alicja Kucharczyk
> > Email address: pinker(at)onet(dot)eu
> > PostgreSQL version: 9.3.4
> > Operating system: RedHat
> > Description:
> >
> > The problem is described here:
> > http://stackoverflow.com/questions/24382158/strange-cleanup-behaviour-with-for-update
> >
> > The main problem is that xmax values stays set with xid of transaction that
> > has already committed. The documentation says: "The identity (transaction
> > ID) of the deleting transaction, or zero for an undeleted row version. It is
> > possible for this column to be nonzero in a visible row version. That
> > usually indicates that the deleting transaction hasn't committed yet, or
> > that an attempted deletion was rolled back."
>
> This isn't a bug. It's expected that xmax sometimes is nonzero for
> undeleted rows. As you cite "It is possible for this column to be
> nonzero in a visible row version.". The list of cases in which that can
> happen isn't exhaustive...
>
> > I have used this feature for a queue to avoid locking, but it doesn't work
> > together with FOR UPDATE clause.
>
> I doubt you can sensibly use xmax for this unless you're willing to
> write server side C code. You're probably better of using something like
> pgq or advisory locks.

I think if the user wants to use xmax this way they are going to have to
install contrib/pageinspect, then query the flags that indicate if xmax
is really expired.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-07-29 15:50:41 Re: BUG #11078: this query crash on array_agg, but there is no array_agg
Previous Message Heikki Linnakangas 2014-07-29 09:03:55 Re: BUG #11032: Prepared transactions do not update pg_last_xact_replay_timestamp() anymore