From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
Cc: Andrew Sackville-West <awest@janrain.com>
Cc: pgsql-bugs@postgresql.org
Cc: Paulo Tanimoto <paulo@janrain.com>
Subject: Re: regression, deadlock in high frequency single-row UPDATE
Date: Fri, 12 Dec 2014 17:52:54 -0300
Message-ID: <20141212205254.GC1768@alvh.no-ip.org> (raw)
In-Reply-To: <548AA8F4.3020905@catalyst.net.nz>
References: <20141208235552.GZ6930@andrew-ThinkPad-X230>
<54868FA2.80003@catalyst.net.nz>
<CAAdHSJk7E5oNuinLwqTzmqGKRHaMmGa5KwBf9BWAmiNfLyHSgw@mail.gmail.com>
<5487B8F2.6050806@catalyst.net.nz>
<20141210193314.GZ1768@alvh.no-ip.org>
<5488C197.3060900@catalyst.net.nz>
<548943C7.2030507@catalyst.net.nz>
<20141211130653.GG1768@alvh.no-ip.org>
<20141211172256.GB20615@alvh.no-ip.org>
<548AA8F4.3020905@catalyst.net.nz>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Mark Kirkwood wrote:
> FWIW - I was having a look at the isolationtester spec. Playing with the
> pgbench setup to see the minimal number of session I needed to provoke the
> deadlock (unpatched 9.5 code) seemed to converge to about 4. I managed to
> still see 1 deadlock with each session only doing 1 transaction - i.e:
>
> $ pgbench -c 4 -C -n -t 1 -f query.sql deadlock
>
> ...which resulted in 1 deadlock. So we may be able to get a reasonable test
> case that shows this up! I'll take a look at setting up a test case later -
> but don't let that stop you doing it 1st :-)
Okay, I created a reproducer ... but it doesn't work. I mean, the
commands are fine: if I execute them manually in four sessions in an
unpatched server I get a deadlock. But isolationtester doesn't know to
handle more than one blocked session, so it just hangs when the third
session blocks after the second one is already blocked. :-(
Here it is anyway. If we get around to improving isolationtester to
handle more blocked sessions, it would be good to add this file.
setup {
DROP TABLE IF EXISTS pktab;
CREATE TABLE pktab (id int PRIMARY KEY, data SERIAL NOT NULL);
INSERT INTO pktab VALUES (1, DEFAULT);
}
teardown {
DROP TABLE pktab;
}
session "s1"
step "s1_advlock" { SELECT pg_advisory_lock(142857); }
step "s1_chain" { UPDATE pktab SET data = DEFAULT; }
step "s1_begin" { BEGIN; }
step "s1_grablock" { SELECT * FROM pktab FOR KEY SHARE; }
step "s1_advunlock" { SELECT pg_advisory_unlock(142857); }
step "s1_commit" { COMMIT; }
session "s2"
step "s2_update" { UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; }
session "s3"
step "s3_update" { UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; }
session "s4"
step "s4_update" { UPDATE pktab SET data = DEFAULT WHERE pg_advisory_lock_shared(142857) IS NOT NULL; }
permutation "s1_advlock" "s2_update" "s3_update" "s4_update" "s1_chain" "s1_grablock" "s1_advunlock" "s1_commit"
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, 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, mark.kirkwood@catalyst.net.nz, awest@janrain.com, paulo@janrain.com
Subject: Re: regression, deadlock in high frequency single-row UPDATE
In-Reply-To: <20141212205254.GC1768@alvh.no-ip.org>
References: <20141208235552.GZ6930@andrew-ThinkPad-X230> <54868FA2.80003@catalyst.net.nz> <CAAdHSJk7E5oNuinLwqTzmqGKRHaMmGa5KwBf9BWAmiNfLyHSgw@mail.gmail.com> <5487B8F2.6050806@catalyst.net.nz> <20141210193314.GZ1768@alvh.no-ip.org> <5488C197.3060900@catalyst.net.nz> <548943C7.2030507@catalyst.net.nz> <20141211130653.GG1768@alvh.no-ip.org> <20141211172256.GB20615@alvh.no-ip.org> <548AA8F4.3020905@catalyst.net.nz> <20141212205254.GC1768@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