Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHfcV-0001a8-ND for pgsql-general@arkaria.postgresql.org; Thu, 23 Nov 2017 00:43:59 +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 1eHfcU-0006oY-Rg for pgsql-general@arkaria.postgresql.org; Thu, 23 Nov 2017 00:43:58 +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 1eHfcU-0006oO-H7 for pgsql-general@lists.postgresql.org; Thu, 23 Nov 2017 00:43:58 +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.89) (envelope-from ) id 1eHfcR-0004an-Mt for pgsql-general@postgresql.org; Thu, 23 Nov 2017 00:43:57 +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 vAN0houK014526; Wed, 22 Nov 2017 19:43:50 -0500 From: Tom Lane To: Justin Pryzby cc: Andres Freund , pgsql-general@postgresql.org Subject: Re: backends stuck in "startup" In-reply-to: <20171122223117.GB5668@telsasoft.com> References: <20171121230926.GA17194@telsasoft.com> <20171121234027.b4n4jlsfda42qb6r@alap3.anarazel.de> <20171122064702.GQ5668@telsasoft.com> <27867.1511375232@sss.pgh.pa.us> <20171122223117.GB5668@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Wed, 22 Nov 2017 16:31:17 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14524.1511397830.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 22 Nov 2017 19:43:50 -0500 Message-ID: <14525.1511397830@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > For starters, I found that PID 27427 has: > (gdb) p proc->lwWaiting > $1 =3D 0 '\000' > (gdb) p proc->lwWaitMode > $2 =3D 1 '\001' To confirm, this is LWLockAcquire's "proc", equal to MyProc? If so, and if LWLockAcquire is blocked at PGSemaphoreLock, that sure seems like a smoking gun. > Note: I've compiled locally PG 10.1 with PREFERRED_SEMAPHORES=3DSYSV to = keep the > service up (and to the degree that serves to verify that avoids the issu= e, > great). Good idea, I was going to suggest that. It will be very interesting to see if that makes the problem go away. > Would you suggest how I can maximize the likelyhood/speed of triggering = that ? > Five years ago, with a report of similar symptoms, you said "You need to= hack > pgbench to suppress the single initialization connection it normally lik= es to > make, else the test degenerates to the one-incoming-connection case" > https://www.postgresql.org/message-id/8896.1337998337%40sss.pgh.pa.us I don't think that case was related at all. My theory suggests that any contended use of an LWLock is at risk, in which case just running pgbench with about as many sessions as you have in the live server ought to be able to trigger it. However, that doesn't really account for your having observed the problem only during session startup, so there may be some other factor involved. I wonder if it only happens during the first wait for an LWLock ... and if so, how could that be? regards, tom lane