From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Oliver Seemann <oseemann@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Update with subselect sometimes returns wrong result
Date: Thu, 19 Dec 2013 23:44:56 -0300
Message-ID: <20131220024455.GP11006@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <20131219155807.GL11006@eldon.alvh.no-ip.org>
References: <CANCipfpfzoYnOz5jj=UZ70_R=CwDHv36dqWSpwsi27vpm1z5sA@mail.gmail.com>
<25601.1385834264@sss.pgh.pa.us>
<20131130214018.GJ31100@awork2.anarazel.de>
<22220.1385880062@sss.pgh.pa.us>
<20131201081919.GF18793@alap2.anarazel.de>
<20131201114514.GG18793@alap2.anarazel.de>
<20131218221343.GG11006@eldon.alvh.no-ip.org>
<20131218223944.GE26481@alap2.anarazel.de>
<20131219005808.GI11006@eldon.alvh.no-ip.org>
<20131219155807.GL11006@eldon.alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Alvaro Herrera escribió:
> Actually, the original coding is better because it enables easier
> writing of other optimizations, such as in the attached which should
> also cure the performance regression noted in bug #8470.
While trying to apply the second bit of this patch (where we try to skip
acquiring a lock that an ancestor subxact already holds), I noticed that
it doesn't work at all; moreover, the whole idea of locking a tuple
twice by another subaxt of the same transaction doesn't work. For
example:
BEGIN;
SELECT tuple FOR NO KEY UPDATE;
SAVEPOINT f;
SELECT tuple FOR UPDATE;
...
This fails to acquire the second lock completely; only the NO KEY UPDATE
lock is stored in the tuple. The reason this happens is that
HeapTupleSatisfiesUpdate returns MayBeUpdated if the Xmax is a plain Xid
LOCK_ONLY by our own transaction. We already commented in some other
thread that maybe we should change this bit of HTSU behavior; but when I
tried to do so to enable this optimization, I found that other routines
die while trying to apply XactLockTableWait to the current transaction.
This sorta makes sense --- it means that if we want to change this, we
will need further surgery to callers of HTSU.
There's another problem which is that this optimization would be
applicable to locks only, not updates. Given this limitation I think it
would be rather pointless to try to do this.
I will keep working at the other part, involving multixacts.
--
Álvaro Herrera 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
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: alvherre@2ndquadrant.com, andres@2ndquadrant.com, tgl@sss.pgh.pa.us, oseemann@gmail.com
Subject: Re: Update with subselect sometimes returns wrong result
In-Reply-To: <20131220024455.GP11006@eldon.alvh.no-ip.org>
References: <CANCipfpfzoYnOz5jj=UZ70_R=CwDHv36dqWSpwsi27vpm1z5sA@mail.gmail.com> <25601.1385834264@sss.pgh.pa.us> <20131130214018.GJ31100@awork2.anarazel.de> <22220.1385880062@sss.pgh.pa.us> <20131201081919.GF18793@alap2.anarazel.de> <20131201114514.GG18793@alap2.anarazel.de> <20131218221343.GG11006@eldon.alvh.no-ip.org> <20131218223944.GE26481@alap2.anarazel.de> <20131219005808.GI11006@eldon.alvh.no-ip.org> <20131219155807.GL11006@eldon.alvh.no-ip.org> <20131220024455.GP11006@eldon.alvh.no-ip.org>
* 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