Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e6fub-0007rb-UZ for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Oct 2017 16:49:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e6fub-0008Ux-6T for pgsql-bugs@arkaria.postgresql.org; Mon, 23 Oct 2017 16:49:13 +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 1e6fua-0008U4-7G for pgsql-bugs@postgresql.org; Mon, 23 Oct 2017 16:49:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e6fuW-0006ju-Nd for pgsql-bugs@postgresql.org; Mon, 23 Oct 2017 16:49:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v9NGn6Di006026; Mon, 23 Oct 2017 12:49:06 -0400 From: Tom Lane To: Chris Hanks cc: pgsql-bugs@postgresql.org Subject: Re: Connections hang indefinitely while taking a LWLockTranche buffer_content lock. In-reply-to: References: <27210.1508697596@sss.pgh.pa.us> Comments: In-reply-to Chris Hanks message dated "Mon, 23 Oct 2017 12:38:27 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6024.1508777346.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 23 Oct 2017 12:49:06 -0400 Message-ID: <6025.1508777346@sss.pgh.pa.us> 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 Chris Hanks writes: > Backtrace of query with PID 22: > #0 0x00007fa23544ed87 in write_call_graph (fd=3D) at gmon= .c:287 > #1 write_gmon () at gmon.c:394 > #2 0x00005639548bf72b in LWLockAcquire (lock=3D0xffff0001, > mode=3DLW_EXCLUSIVE) at > /build/postgresql-9.6-HEXeEe/postgresql-9.6-9.6.1/build/../src/backend/st= orage/lmgr/lwlock.c:1287 > #3 0x00005639546707c1 in ginHeapTupleFastInsert > (ginstate=3Dginstate@entry=3D0x7ffef442af00, > collector=3Dcollector@entry=3D0x7ffef442aee0) > at /build/postgresql-9.6-HEXeEe/postgresql-9.6-9.6.1/build/../src/bac= kend/access/gin/ginfast.c:314 > Backtrace of query with PID 16987 > #0 0x00007fa23544ed87 in write_call_graph (fd=3D) at gmon= .c:287 > #1 write_gmon () at gmon.c:394 > #2 0x00005639548bf72b in LWLockAcquire (lock=3D0xffff000f, > mode=3DLW_EXCLUSIVE) at > /build/postgresql-9.6-HEXeEe/postgresql-9.6-9.6.1/build/../src/backend/st= orage/lmgr/lwlock.c:1287 > #3 0x00005639546704e0 in ginHeapTupleFastInsert > (ginstate=3Dginstate@entry=3D0x7ffef442af00, > collector=3Dcollector@entry=3D0x7ffef442aee0) So it looks like ginHeapTupleFastInsert is doing something that carries a risk of deadlocking on two or more LWLocks, if multiple processes try to insert index entries concurrently. There's no deadlock detection in the LWLock infrastructure --- that's one of the things that makes it "lightweight" locks --- so callers have to avoid such coding patterns. This is probably enough info for us to identify the exact cause. But I don't have time to look right this minute, and am not the hacker most familiar with the GIN infrastructure anyway. Anyone want to look for the bug? regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs