pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
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 12:05:31 +1300
Message-ID: <548A233B.8030003@catalyst.net.nz> (raw)
In-Reply-To: <20141211172256.GB20615@alvh.no-ip.org>
References: <20140804161205.GA30380@andrew-ThinkPad-X230>
	<20140804163027.GI5475@eldon.alvh.no-ip.org>
	<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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 12/12/14 06:22, Alvaro Herrera wrote:
> Alvaro Herrera wrote:
>
>> I'm going to experiment with that idea and see if it leads to a
>> solution.  I tried the other idea yesterday (to keep the HW tuple lock
>> we acquire in heap_lock_tuple until heap_update is done) but aside from
>> being very complicated and bug-prone, it doesn't solve the problem
>> anyway.
>
> Here's a preliminary patch.  It does solve the deadlock in my simplified
> test case.  If Andrew can confirm that it fixes his original problem
> too, that'd be good.
>
> Before this can be committed I need an isolationtester spec file that
> reproduces the problem.  Now that I understand why it happens it should
> be easy to produce: just have a transaction that does BEGIN, then the
> insert, and keeps the transaction open; enough other sessions run the
> UPDATE until the problem pops up.  (Also, comments on
> Would_MultiXactIdWait_Block need work.)
>
> FWIW this code should also have slightly better performance than the
> original coding, since the heavyweight tuple lock acquisition is skipped
> in some cases.  Not sure if that is measurable, though.  Maybe in
> extreme cases such as the one in #8470 ...
>

Yeah, works for me too. I've tried your simplified and also Andrew's 
original schema + queries against 9.5devel with deadlock.patch applied 
(neither show any deadlocks in that case).

Cheers

Mark


-- 
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 (34+ messages)  latest in thread

Message-ID: <548A233B.8030003@catalyst.net.nz>
Permalink:  ../548A233B.8030003@catalyst.net.nz/
Also on:    postgresql.org/message-id/548A233B.8030003@catalyst.net.nz

 · 

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: mark.kirkwood@catalyst.net.nz, alvherre@2ndquadrant.com, awest@janrain.com, paulo@janrain.com
  Subject: Re: regression, deadlock in high frequency single-row UPDATE
  In-Reply-To: <548A233B.8030003@catalyst.net.nz>
  References: <20140804161205.GA30380@andrew-ThinkPad-X230> <20140804163027.GI5475@eldon.alvh.no-ip.org> <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> <548A233B.8030003@catalyst.net.nz>

* 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