Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XzCnn-0000jo-0h for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Dec 2014 23:05:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XzCnm-0003jT-7q for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Dec 2014 23:05:42 +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 1XzCnl-0003jI-DZ for pgsql-bugs@postgresql.org; Thu, 11 Dec 2014 23:05:41 +0000 Received: from mail.catalyst.net.nz ([2404:130:0:10::40:0]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XzCng-0004lc-Dc for pgsql-bugs@postgresql.org; Thu, 11 Dec 2014 23:05:38 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 04DA231D28; Fri, 12 Dec 2014 12:05:33 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VpXqV2RL1ohY; Fri, 12 Dec 2014 12:05:32 +1300 (NZDT) Received: from [IPv6:2404:130:0:1000:6cb4:3dc1:8136:89c1] (unknown [IPv6:2404:130:0:1000:6cb4:3dc1:8136:89c1]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id 6A1FB31FF2; Fri, 12 Dec 2014 12:05:31 +1300 (NZDT) Message-ID: <548A233B.8030003@catalyst.net.nz> Date: Fri, 12 Dec 2014 12:05:31 +1300 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Alvaro Herrera CC: Andrew Sackville-West , pgsql-bugs@postgresql.org, Paulo Tanimoto Subject: Re: regression, deadlock in high frequency single-row UPDATE References: <20140804161205.GA30380@andrew-ThinkPad-X230> <20140804163027.GI5475@eldon.alvh.no-ip.org> <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> In-Reply-To: <20141211172256.GB20615@alvh.no-ip.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 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