pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@2ndquadrant.com>
To: Oliver Seemann <oseemann@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Update with subselect sometimes returns wrong result
Date: Mon, 2 Dec 2013 23:41:10 +0100
Message-ID: <20131202224110.GA30079@awork2.anarazel.de> (raw)
In-Reply-To: <CANCipfqjL0hcz+3udLumjHinYgSMU7jK93upoZx-dqkYYSEJRw@mail.gmail.com>
References: <CANCipfpfzoYnOz5jj=UZ70_R=CwDHv36dqWSpwsi27vpm1z5sA@mail.gmail.com>
	<20131201121209.GH18793@alap2.anarazel.de>
	<CANCipfqjL0hcz+3udLumjHinYgSMU7jK93upoZx-dqkYYSEJRw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 2013-12-02 22:55:30 +0100, Oliver Seemann wrote:
> 2013/12/1 Andres Freund <andres@2ndquadrant.com>:
> > To get rid of that ambiguity, I suggest rewriting the query to look
> > like:
> > WITH locked_row AS (
> >     SELECT id FROM t1 LIMIT 1 FOR UPDATE
> > )
> > UPDATE t1 SET id = t1.id
> > FROM (SELECT * FROM locked_row) locked
> > WHERE t1.id = locked.id
> > RETURNING t1.id;
> 
> Thanks for looking into this and even providing a workaround!
> 
> The patch you posted previously is incomplete, right? Because I can
> still trigger the problem with the patch applied on top of git master.
> (I use autovacuum_naptime = 1s to reliably trigger within 1-5 seconds).

The patch isn't for this issue, it's for something Tom noticed while
investigating it. Purely a performance optimization/fix for a
performance regression - albeit a noticeable one.
I'd judge that there's about zero chance that the issue can be fixed in
the stable branches, the likelihood of breaking other working code due
to the require semantic changes are far too great.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (24+ messages)  latest in thread

Message-ID: <20131202224110.GA30079@awork2.anarazel.de>
Permalink:  ../20131202224110.GA30079@awork2.anarazel.de/
Also on:    postgresql.org/message-id/20131202224110.GA30079@awork2.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@2ndquadrant.com, oseemann@gmail.com
  Subject: Re: Update with subselect sometimes returns wrong result
  In-Reply-To: <20131202224110.GA30079@awork2.anarazel.de>
  References: <CANCipfpfzoYnOz5jj=UZ70_R=CwDHv36dqWSpwsi27vpm1z5sA@mail.gmail.com> <20131201121209.GH18793@alap2.anarazel.de> <CANCipfqjL0hcz+3udLumjHinYgSMU7jK93upoZx-dqkYYSEJRw@mail.gmail.com> <20131202224110.GA30079@awork2.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox