Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHOoh-0007VM-3t for pgsql-general@arkaria.postgresql.org; Wed, 22 Nov 2017 06:47:27 +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 1eHOog-0003vZ-GT for pgsql-general@arkaria.postgresql.org; Wed, 22 Nov 2017 06:47:26 +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 1eHOof-0003vO-V6 for pgsql-general@lists.postgresql.org; Wed, 22 Nov 2017 06:47:26 +0000 Received: from mail-it0-x231.google.com ([2607:f8b0:4001:c0b::231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eHOoL-0006sq-L5 for pgsql-general@postgresql.org; Wed, 22 Nov 2017 06:47:24 +0000 Received: by mail-it0-x231.google.com with SMTP id n134so5067892itg.3 for ; Tue, 21 Nov 2017 22:47:05 -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=WNBtFb22eTLfePTnQIhoA1mrmTmFO8Jgn3sdrXQINYc=; b=jJYGaGNyHNjrXZY1xiZITjpiUwVTKX8hth8qaV09VHFZfJdRmtp2pn8c1x0ZLlR4BH jlqQbwJy9so3wkLqmRbJvVDXnPLLkI0J53GavZk73wl7mkVDFoVIaFp+oI4zVkzDQaJ6 cjcV3M+rBIgD+n9Ul7I6vTO6doJ9mWs0RIhEZC4e88U0I9sT2y6w4eIkogn4vkatluuO OdPOrwMqFfEN3DMAx6PH4TZjM3ZJju+vPl/RJltSRrYst+Yfj8fxU314gsw6lqej0o2e ern4unkKsSvhBXRbL0iHBmp4OqrSCxOppF1g9FBSe6qoVPIzpQy1i+Ck8MxM8fWcZ+Tz bEfg== 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=WNBtFb22eTLfePTnQIhoA1mrmTmFO8Jgn3sdrXQINYc=; b=cm0fqD+Bg9OdQZlL+0OGEGyEMThT+uemMa6/KcRWn+hAZVsbQok4oEiwdcatCA0ou8 yaiYYxfjAP6DDG7QavzBAFzv+BgCQ7M+xaTeARyQ7jQkx003wL6XVzq074U1qLN8TEPJ MwE+S+pRwE1wdvbwPBvBflJ+uD4nFrAGxYdG+iou+r9ZLQjbPq7ygLEVQnMg2uqhuCvL xTl2hCO/Qyjk50lrG9kcUfzGDVi6YzrWtpo+vYMC24q9hofPfHa0Wx5S2+K2r4cuIauy dFLFivaAKqb9Z/HqqkD28udPQt8+uk+NTn+1EOuifyXrNyI24A3/bSrE7rJTBUBE4p1y exAg== X-Gm-Message-State: AJaThX7ZR5svu9NGK5OcWnqfHgQbLAyxYs6aQwle9ZttHoB938d+0wVd t7C9ILt0+vWbMgDo+wa4RmtDoWAiVyI= X-Google-Smtp-Source: AGs4zMa6Fbv6SUVFTcjsviMlUcmfLjllH7W8dNNWdykpRqc+BEwr6rLJo+RXYvQ8TxvBo91DVTMZqg== X-Received: by 10.36.215.3 with SMTP id y3mr5322499itg.22.1511333224256; Tue, 21 Nov 2017 22:47:04 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id 128sm531684iow.38.2017.11.21.22.47.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 22:47:03 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id BAD09800FE7; Wed, 22 Nov 2017 00:47:02 -0600 (CST) Date: Wed, 22 Nov 2017 00:47:02 -0600 From: Justin Pryzby To: Andres Freund Cc: pgsql-general@postgresql.org Subject: Re: backends stuck in "startup" Message-ID: <20171122064702.GQ5668@telsasoft.com> References: <20171121230926.GA17194@telsasoft.com> <20171121234027.b4n4jlsfda42qb6r@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171121234027.b4n4jlsfda42qb6r@alap3.anarazel.de> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Nov 21, 2017 at 03:40:27PM -0800, Andres Freund wrote: > Hi, > > On 2017-11-21 17:09:26 -0600, Justin Pryzby wrote: > > I'm sorry to report this previously reported problem is happening again, > > starting shortly after pg_upgrading a customer to PG10.1 from 9.6.5. > > > > As $subject: backends are stuck in startup for minutes at a time. I didn't > > strace this time, but I believe last time I saw one was waiting in a futex. > > Could you try stracing next time? I straced all the "startup" PIDs, which were all in futex, without exception: [pryzbyj@TS-DB ~]$ sudo strace `ps h --sort start_time -o pid,args -u postgres |awk '/startup$/{print "-p"$1}'` 2>&1 |tee -a /tmp/strace-pg-backends Process 3611 attached Process 6081 attached [pid 6081] futex(0x7ff4314000f8, FUTEX_WAIT, 0, NULL [pid 3611] futex(0x7ff431400138, FUTEX_WAIT, 0, NULL [pid 3354] futex(0x7ff431400258, FUTEX_WAIT, 0, NULL [pid 3117] futex(0x7ff4314002b8, FUTEX_WAIT, 0, NULL [pid 2948] futex(0x7ff431400378, FUTEX_WAIT, 0, NULL [pid 2925] futex(0x7ff4314003d8, FUTEX_WAIT, 0, NULL [pid 2789] futex(0x7ff431400438, FUTEX_WAIT, 0, NULL [pid 2752] futex(0x7ff4314004b8, FUTEX_WAIT, 0, NULL [pid 2663] futex(0x7ff431400618, FUTEX_WAIT, 0, NULL [pid 2661] futex(0x7ff431400638, FUTEX_WAIT, 0, NULL [pid 2624] futex(0x7ff431400678, FUTEX_WAIT, 0, NULL [pid 2576] futex(0x7ff4314006f8, FUTEX_WAIT, 0, NULL [pid 365] futex(0x7ff431400718, FUTEX_WAIT, 0, NULL [pid 326] futex(0x7ff431400798, FUTEX_WAIT, 0, NULL [pid 32704] futex(0x7ff431400898, FUTEX_WAIT, 0, NULL [pid 32309] futex(0x7ff431400938, FUTEX_WAIT, 0, NULL [pid 32292] futex(0x7ff431400a18, FUTEX_WAIT, 0, NULL [pid 32170] futex(0x7ff431400ad8, FUTEX_WAIT, 0, NULL [pid 32134] futex(0x7ff431400b58, FUTEX_WAIT, 0, NULL [pid 31987] futex(0x7ff431400bf8, FUTEX_WAIT, 0, NULL [pid 31962] futex(0x7ff431400c58, FUTEX_WAIT, 0, NULL [pid 31817] futex(0x7ff431400d38, FUTEX_WAIT, 0, NULL [pid 31807] futex(0x7ff431400d98, FUTEX_WAIT, 0, NULL [pid 29664] futex(0x7ff431400e98, FUTEX_WAIT, 0, NULL [pid 29462] futex(0x7ff431400ef8, FUTEX_WAIT, 0, NULL [pid 29426] futex(0x7ff431400f38, FUTEX_WAIT, 0, NULL [pid 29258] futex(0x7ff431401058, FUTEX_WAIT, 0, NULL [pid 29227] futex(0x7ff431402f58, FUTEX_WAIT, 0, NULL [pid 29107] futex(0x7ff431401138, FUTEX_WAIT, 0, NULL [pid 29071] futex(0x7ff431401198, FUTEX_WAIT, 0, NULL [pid 28942] futex(0x7ff431401258, FUTEX_WAIT, 0, NULL [pid 28924] futex(0x7ff431401298, FUTEX_WAIT, 0, NULL [pid 26942] futex(0x7ff431401418, FUTEX_WAIT, 0, NULL [pid 25278] futex(0x7ff431401438, FUTEX_WAIT, 0, NULL [pid 24909] futex(0x7ff431401598, FUTEX_WAIT, 0, NULL [pid 24908] futex(0x7ff4314015b8, FUTEX_WAIT, 0, NULL [pid 24852] futex(0x7ff4314015f8, FUTEX_WAIT, 0, NULL [pid 24851] futex(0x7ff431401618, FUTEX_WAIT, 0, NULL [pid 24585] futex(0x7ff4314016f8, FUTEX_WAIT, 0, NULL [pid 24584] futex(0x7ff431401718, FUTEX_WAIT, 0, NULL [pid 24478] futex(0x7ff431401918, FUTEX_WAIT, 0, NULL [pid 24476] futex(0x7ff431401958, FUTEX_WAIT, 0, NULL [pid 24470] futex(0x7ff4314019d8, FUTEX_WAIT, 0, NULL [pid 24464] futex(0x7ff431401ad8, FUTEX_WAIT, 0, NULL [pid 24458] futex(0x7ff431401bb8, FUTEX_WAIT, 0, NULL [pid 24456] futex(0x7ff431401b98, FUTEX_WAIT, 0, NULL [pid 24450] futex(0x7ff431401c58, FUTEX_WAIT, 0, NULL [pid 24448] futex(0x7ff431401c98, FUTEX_WAIT, 0, NULL [pid 24439] futex(0x7ff431401cf8, FUTEX_WAIT, 0, NULL [pid 24323] futex(0x7ff431401e38, FUTEX_WAIT, 0, NULL [pid 24322] futex(0x7ff431401e58, FUTEX_WAIT, 0, NULL [pid 23057] futex(0x7ff431401fd8, FUTEX_WAIT, 0, NULL [pid 23055] futex(0x7ff431402038, FUTEX_WAIT, 0, NULL [pid 21826] futex(0x7ff4314021f8, FUTEX_WAIT, 0, NULL [pid 21824] futex(0x7ff431402238, FUTEX_WAIT, 0, NULL [pid 21794] futex(0x7ff431402298, FUTEX_WAIT, 0, NULL [pid 21792] futex(0x7ff431402638, FUTEX_WAIT, 0, NULL [pid 21791] futex(0x7ff431402af8, FUTEX_WAIT, 0, NULL [pid 21790] futex(0x7ff431402c98, FUTEX_WAIT, 0, NULL [pid 21786] futex(0x7ff431402478, FUTEX_WAIT, 0, NULL [pid 21785] futex(0x7ff431402758, FUTEX_WAIT, 0, NULL [pid 21784] futex(0x7ff431403098, FUTEX_WAIT, 0, NULL [pid 21768] futex(0x7ff431402718, FUTEX_WAIT, 0, NULL [pid 21662] futex(0x7ff431402338, FUTEX_WAIT, 0, NULL [pid 21648] futex(0x7ff431402c38, FUTEX_WAIT, 0, NULL [pid 21630] futex(0x7ff4314024d8, FUTEX_WAIT, 0, NULL [pid 21591] futex(0x7ff431402278, FUTEX_WAIT, 0, NULL [pid 21590] futex(0x7ff431402bf8, FUTEX_WAIT, 0, NULL Also: [pryzbyj@TS-DB ~]$ date;ps -O lstart,wchan=9999999999999999999999 -u postgres --sort start_time |grep startup$ Wed Nov 22 00:47:41 EST 2017 1990 Wed Nov 22 00:36:44 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53934) startup 2007 Wed Nov 22 00:36:44 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53945) startup 2014 Wed Nov 22 00:36:44 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53946) startup 2042 Wed Nov 22 00:36:48 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.248(51353) startup 2043 Wed Nov 22 00:36:48 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.252(52122) startup 2047 Wed Nov 22 00:36:49 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.253(46696) startup 2049 Wed Nov 22 00:36:49 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.249(60135) startup 2052 Wed Nov 22 00:36:50 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53947) startup 2095 Wed Nov 22 00:37:13 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.248(51355) startup 2096 Wed Nov 22 00:37:14 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.249(60137) startup 2097 Wed Nov 22 00:37:15 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53949) startup 2178 Wed Nov 22 00:37:43 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.253(46698) startup 2188 Wed Nov 22 00:38:00 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.252(52124) startup 2331 Wed Nov 22 00:38:30 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.248(51357) startup 2332 Wed Nov 22 00:38:30 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.249(60139) startup 2333 Wed Nov 22 00:38:31 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53951) startup 2529 Wed Nov 22 00:39:00 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.253(46700) startup 2530 Wed Nov 22 00:39:01 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.248(51358) startup 2533 Wed Nov 22 00:39:01 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.247(53952) startup 2535 Wed Nov 22 00:39:01 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.252(52125) startup 2549 Wed Nov 22 00:39:01 2017 futex_wait_queue_me S ? 00:00:00 postgres: xx xx xx.253(46701) startup [...] > Don't think it's conclusive that they're all continually waiting rather than > contending on a few locks. As soon as you attach to one backend a contended > lock situation can quickly turn into standstill if you end up interrupting a > process that holds a lock. I didn't understand what you mean. By "attach" do you mean attach with strace? gdb? Or ?? I also tried stracing all (400) postgres PIDs, which didn't magically unlock them.. sudo strace `ps h --sort start_time -o pid,args -u postgres |awk '/|startup$/{print "-p"$1}'` 2>> /tmp/strace-pg-backends3 & FYI these AREN'T being rebuilt very often: [pryzbyj@TS-DB ~]$ sudo sh -c "find /var/lib/pgsql/ -name 'pg_internal.init' -print0 |xargs -r0 ls -lt" -rw------- 1 postgres postgres 136164 Nov 21 21:50 /var/lib/pgsql/10/data/base/16404/pg_internal.init -rw------- 1 postgres postgres 21340 Nov 21 21:50 /var/lib/pgsql/10/data/global/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 21:47 /var/lib/pgsql/10/data/base/16406/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 21:32 /var/lib/pgsql/10/data/base/16410/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 21:28 /var/lib/pgsql/10/data/base/16401/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 21:21 /var/lib/pgsql/10/data/base/16403/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 21:13 /var/lib/pgsql/10/data/base/13451/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 21:13 /var/lib/pgsql/10/data/base/16408/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 20:59 /var/lib/pgsql/10/data/base/16411/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 20:56 /var/lib/pgsql/10/data/base/16402/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 20:01 /var/lib/pgsql/10/data/base/1/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 20:01 /var/lib/pgsql/10/data/base/16409/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 20:00 /var/lib/pgsql/10/data/base/16407/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 20:00 /var/lib/pgsql/10/data/base/16405/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 19:59 /var/lib/pgsql/10/data/base/16400/pg_internal.init -rw------- 1 postgres postgres 136164 Nov 21 17:17 /var/lib/pgsql/10/data/base/13450/pg_internal.init [pryzbyj@TS-DB ~]$ date Wed Nov 22 00:45:14 EST 2017 And it's not a minor overhead: [pryzbyj@TS-DB ~]$ time psql newn -c 'SELECT 1' psql: FATAL: terminating connection due to administrator command real 10m22.089s Justin