Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHdYH-0004YY-60 for pgsql-general@arkaria.postgresql.org; Wed, 22 Nov 2017 22:31:29 +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 1eHdYF-0005bg-T0 for pgsql-general@arkaria.postgresql.org; Wed, 22 Nov 2017 22:31:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eHdYF-0005bW-HI for pgsql-general@lists.postgresql.org; Wed, 22 Nov 2017 22:31:27 +0000 Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eHdYA-0001rP-MG for pgsql-general@postgresql.org; Wed, 22 Nov 2017 22:31:26 +0000 Received: by mail-io0-x234.google.com with SMTP id z74so24777245iof.12 for ; Wed, 22 Nov 2017 14:31:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=B0Avp48tFeUx/H/lbGG4zNzpfhGK3mW8DVy+v+oe744=; b=VrUkJ3m4RJ11cmO78NOh5XqGeP6Sai3BkktrJ6ctl9HbgU9jrKkEv5hmi5oxoXz1OF PmkU6SzwsrEQ+5RbmpfazGv2UQv+B7qEdIiwo3kW+mwhV5co1os8WGAJjJSukmEmMK7m zPI8bMlqYX7ERqwO2milmR5juOMGmV4JDHBlvEQPBFMrxCH6X6jFQuOXr8HzOLexccZu ch2LSfXuk/q6zLoWTxb7RGbj6HfogMcOui1mUnD3OmoOinQuDDPzu6Rtb9FBN3uW6Xhj 9It2i6oBtI61yJMyYovI1yA072tsqJ1QjXl7twYadDeSsyt1+RPqgUs2O6uxYTwwico6 Srkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=B0Avp48tFeUx/H/lbGG4zNzpfhGK3mW8DVy+v+oe744=; b=tY6RRLdneLciZoBf8hCuZOdnFH+bwGAqYQmQ4QyD0nyyjPQbcqHgnlZrC8W9vaYgHP Kc3w3z0+F1zRPLUuqrij1YMLPU5lCK6TAaOsg3egtqqGcjVAETZVpzbqWcz6dWen4hBn w7fVIe1RNFRTKetHwoGlb60dhcC1aNVgB9BxojOWtimYWyMQzJT8kyheYD0H6s1tbbG/ hIoks6BlS2k/Y7qKZYnkjz0sSsuVftHxfcH3WPX93is7BWmqhuTCLGqO3KEiQ6Rstl1R B/kXgHkmamlMk9QE5KG42aHMDoO1wY2tf9VdcI5HcQUGFkUUUxsZF/TEZ0EXhNFHcm/E e1Ug== X-Gm-Message-State: AJaThX4hb7M7DL7C7mFoqY5X4TT5lKX9vD84+NcPpmZA/FIG6XVoLvMq maZq61XvP2EVVPcJ+QAyGIJxgA== X-Google-Smtp-Source: AGs4zMZayj2sWz+D/VxbgUgSnNf2KyaGYieo7VRY8XpPmMIywkrviADSr7/htS/2+TJtTC3z6x5xOw== X-Received: by 10.107.8.140 with SMTP id h12mr23588729ioi.270.1511389879330; Wed, 22 Nov 2017 14:31:19 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id k23sm2470410iti.22.2017.11.22.14.31.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 14:31:18 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id D749880102B; Wed, 22 Nov 2017 16:31:17 -0600 (CST) Date: Wed, 22 Nov 2017 16:31:17 -0600 From: Justin Pryzby To: Tom Lane Cc: Andres Freund , pgsql-general@postgresql.org Subject: Re: backends stuck in "startup" Message-ID: <20171122223117.GB5668@telsasoft.com> References: <20171121230926.GA17194@telsasoft.com> <20171121234027.b4n4jlsfda42qb6r@alap3.anarazel.de> <20171122064702.GQ5668@telsasoft.com> <27867.1511375232@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27867.1511375232@sss.pgh.pa.us> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Nov 22, 2017 at 01:27:12PM -0500, Tom Lane wrote: > Justin Pryzby writes: > > On Tue, Nov 21, 2017 at 03:40:27PM -0800, Andres Freund wrote: > >> Could you try stracing next time? > > > I straced all the "startup" PIDs, which were all in futex, without exception: > > If you've got debug symbols installed, could you investigate the states > of the LWLocks the processes are stuck on? > > My hypothesis about a missed memory barrier would imply that there's (at > least) one process that's waiting but is not in the lock's wait queue and > has MyProc->lwWaiting == false, while the rest are in the wait queue and > have MyProc->lwWaiting == true. Actually chasing through the list > pointers would be slightly tedious, but checking MyProc->lwWaiting, > and maybe MyProc->lwWaitMode, in each process shouldn't be too hard. > Also verify that they're all waiting for the same LWLock (by address). I believe my ~40 cores are actually for backends from two separate instances of this issue on the VM, as evidenced by different argv pointers. And for each instance, I have cores for only a fraction of the backends (max_connections=400). For starters, I found that PID 27427 has: (gdb) p proc->lwWaiting $1 = 0 '\000' (gdb) p proc->lwWaitMode $2 = 1 '\001' ..where all the others have lwWaiting=1 For #27427: (gdb) p *lock $27 = {tranche = 59, state = {value = 1627389952}, waiters = {head = 147, tail = 308}} (gdb) info locals mustwait = 1 '\001' proc = 0x7f1a77dba500 result = 1 '\001' extraWaits = 0 __func__ = "LWLockAcquire" And at this point I have to ask for help how to finish traversing these structures. I could upload cores for someone (I don't think there's anything too private) but so far I have 16GB gz compressed cores. Note: I've compiled locally PG 10.1 with PREFERRED_SEMAPHORES=SYSV to keep the service up (and to the degree that serves to verify that avoids the issue, great). But I could start an instance running pgbench to try to trigger on this VM, with smaller shared_buffers and backends/clients to allow full cores of every backend (I don't think I'll be able to dump all 400 cores each up to 2GB from the production instance). 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 likes to make, else the test degenerates to the one-incoming-connection case" https://www.postgresql.org/message-id/8896.1337998337%40sss.pgh.pa.us ..but, pgbench --connect seems to do what's needed(?) (I see that dates back to 2001, having been added at ba708ea3). (I don't know there's any suggestion or reason to be believe the bug is specific to connection/startup phase, or that it's a necessary or sufficient to hit the bug, but it's at least known to be impacted and all I have to go on for now). Justin