Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XzXCw-0006UE-F5 for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Dec 2014 20:53:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XzXCv-0006RT-BU for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Dec 2014 20:53:01 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XzXCt-0006RM-L9 for pgsql-bugs@postgresql.org; Fri, 12 Dec 2014 20:52:59 +0000 Received: from outmail149078.authsmtp.net ([62.13.149.78]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XzXCo-0006wb-RW for pgsql-bugs@postgresql.org; Fri, 12 Dec 2014 20:52:57 +0000 Received: from mail-c235.authsmtp.com (mail-c235.authsmtp.com [62.13.128.235]) by punt17.authsmtp.com (8.14.2/8.14.2/) with ESMTP id sBCKqlBo050208; Fri, 12 Dec 2014 20:52:47 GMT Received: from alvin.alvh.no-ip.org (client-186-9-239-88.imovil.entelpcs.cl [186.9.239.88] (may be forged)) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id sBCKqiVP032732; Fri, 12 Dec 2014 20:52:45 GMT Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 50596792; Fri, 12 Dec 2014 17:52:54 -0300 (CLST) Date: Fri, 12 Dec 2014 17:52:54 -0300 From: Alvaro Herrera To: Mark Kirkwood Cc: Andrew Sackville-West , pgsql-bugs@postgresql.org, Paulo Tanimoto Subject: Re: regression, deadlock in high frequency single-row UPDATE Message-ID: <20141212205254.GC1768@alvh.no-ip.org> References: <20141208235552.GZ6930@andrew-ThinkPad-X230> <54868FA2.80003@catalyst.net.nz> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <548AA8F4.3020905@catalyst.net.nz> User-Agent: Mutt/1.5.23 (2014-03-12) X-Server-Quench: d366b201-8240-11e4-b396-002590a15da7 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZcSBoa BzkeAQdJTRslYBtL RB4bawxAL0wMSABN M15eIxoPcUtFHxZ1 VjUUWVRVVE1zWWlw aQBVa0tcakxQVhto U0FXSlpNEQ1vHhxP RWxtKVgrEWVGe3x3 ZkQsX3NbWUI0IUV7 RBxWFWwbbWVkaH0e URVcalFXeQVXfh9H b1l/BXIINTQAKBg1 TUcAFQ0eBgAXMila WAwWNlMVRwJDEjM1 SxQFFjZnHEtNRyQ8 L1QoMFMFAUsXOVR6 KlonVlYVdgUVFUVj J21kPAIx X-Authentic-SMTP: 61633235383639.1023:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 186.9.239.88/587 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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