Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ehv0y-0001hv-RY for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Feb 2018 10:25:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ehv0x-0004Zv-HN for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Feb 2018 10:25:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ehuei-0006e4-9M for pgsql-bugs@lists.postgresql.org; Sat, 03 Feb 2018 10:02:44 +0000 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ehuef-00074j-A1 for pgsql-bugs@lists.postgresql.org; Sat, 03 Feb 2018 10:02:42 +0000 Received: from mail1.pinkwin.com ([IPv6:2001:984:a009:1:5d79:41bf:51da:729f]) by smtp-cloud7.xs4all.net with ESMTP id hueaeeIjY3A62hueceWFlj; Sat, 03 Feb 2018 11:02:38 +0100 Received: from localhost (localhost [127.0.0.1]) by mail1.pinkwin.com (Postfix) with ESMTP id D9F4861DCD; Sat, 3 Feb 2018 11:02:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at pinkwin.com Received: from mail1.pinkwin.com ([127.0.0.1]) by localhost (mail1.pinkwin.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EMyPp8CyHYMd; Sat, 3 Feb 2018 11:02:24 +0100 (CET) Received: from mail.pinkwin.com (localhost [IPv6:::1]) by mail1.pinkwin.com (Postfix) with ESMTP id A17A961D9F; Sat, 3 Feb 2018 11:02:24 +0100 (CET) Received: from 192.168.178.70 (SquirrelMail authenticated user mark) by mail.pinkwin.com with HTTP; Sat, 3 Feb 2018 11:02:24 +0100 Message-ID: In-Reply-To: <40198189.6847478.1516865520664.JavaMail.app@lor1-app12219.prod.linkedin.com> References: <40198189.6847478.1516865520664.JavaMail.app@lor1-app12219.prod.linkedin.com> Date: Sat, 3 Feb 2018 11:02:24 +0100 Subject: Re: BUG #15026: Deadlock using GIST index From: "Mark Scheffer" To: pgsql-bugs@lists.postgresql.org Cc: pg2401k@pinkwin.com User-Agent: SquirrelMail/1.4.23 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-CMAE-Envelope: MS4wfAbo6P5nIG3P5Coiyx4t5CCP71mgzOY92I0BRCbxG8BxzE4dkiSVTuoKPFOq/rgNgvr8Afb/cqTibnsyYIXCPSWn5X1nEDqFyru0LUROl5BXUksF32sE 2Wmgb3lXAmTNOQWUjrADvU4+44aC1AJFj49fOmSyNpihVYwMKaqriHe5lQhmDcXkK5BnlYw1q4cNfdZS5p6NhDOZUq7GE+hef/cp1hLnzn5Yj9mXYVfaN3aN 7GlhzWDH0QcleIp4CU0HDg== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, Digging deeper into source code of backend/executor/execIndexing.c, I found following: * Exclusion Constraints * --------------------- ... * * There is a chance of deadlock, if two backends insert a tuple at the * same time, and then perform the scan to check for conflicts. They will * find each other's tuple, and both try to wait for each other. The * deadlock detector will detect that, and abort one of the transactions. * That's fairly harmless, as one of them was bound to abort with a * "duplicate key error" anyway, although you get a different error * message. I guess that my example has this deadlock... I'm not so happy with "That's fairly harmless". In my case I'm processing messages from several sessions at a rate of more than 1000 messages per second per session. With default deadlock timeout of 1 second, at least two sessions may block and this may have impact on other sessions which may cascade into a lot of sessions being in a dead-lock. I had a situation where throughput dropped to 6 messages per second.... Very simple example of this problem: 1. lookup a record for entity E using exclusion constraint 2. if it does not exist: insert the record 3. If this insert fails, back to 1. If n sessions try to execute this in parallel, the wait time will be n-1 seconds. Any chance in changing current Postgresql behavior? Regards, Mark