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 1etbMg-0004PC-LD for pgsql-general@arkaria.postgresql.org; Wed, 07 Mar 2018 15:52:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1etbMf-0002Ma-9B for pgsql-general@arkaria.postgresql.org; Wed, 07 Mar 2018 15:52:25 +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.89) (envelope-from ) id 1etbMf-0002MR-1G for pgsql-general@lists.postgresql.org; Wed, 07 Mar 2018 15:52:25 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1etbMc-000370-G9 for pgsql-general@lists.postgresql.org; Wed, 07 Mar 2018 15:52:24 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 9B4CC40E51; Wed, 7 Mar 2018 16:52:20 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id m4WtZsuSqQNA; Wed, 7 Mar 2018 16:52:19 +0100 (CET) Message-ID: <1520437938.2402.10.camel@cybertec.at> Subject: Re: Help troubleshooting SubtransControlLock problems From: Laurenz Albe To: Scott Frazer , pgsql-general@lists.postgresql.org Date: Wed, 07 Mar 2018 16:52:18 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Scott Frazer wrote: > Hi, we have a Postgres 9.6 setup using replication that has recently started seeing a lot of processes stuck in > "SubtransControlLock" as a wait_event on the read-replicas. Like this, only usually about 300-800 of them: > > > 179706 | LWLockNamed | SubtransControlLock > 186602 | LWLockNamed | SubtransControlLock > 186606 | LWLockNamed | SubtransControlLock > 180947 | LWLockNamed | SubtransControlLock > 186621 | LWLockNamed | SubtransControlLock > > The server then begins to crawl, with some queries just never finishing until I finally shut the server down. > > Searching for that particular combo of wait_event_type and wait_event only seems to turn up the page > about statistics collection, but no helpful information on troubleshooting this lock. > > Restarting the replica server clears the locks and allows us to start working again, but it's happened > twice now in 12 hours and I'm worried it will happen again. > > Does anyone have any advice on where to start looking? I don't think there is any connection to statistics collection. This lock is used when subtransactions (SAVEPOINTs in SQL or EXCEPTION blocks in PL/pgSQL) are created, read or removed. This sounds like a PostgreSQL bug. What is the exact PostgreSQL version you are running? It would be cool if you could get a stack trace from the backend that is holding the lock. Yours, Laurenz Albe