Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ff4f1-0005YT-Jg for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jul 2018 14:39:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ff4f0-0007RS-2v for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jul 2018 14:39:34 +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 1ff4ez-0007RK-S5 for pgsql-hackers@lists.postgresql.org; Mon, 16 Jul 2018 14:39:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ff4ex-0002Cz-B0 for pgsql-hackers@postgresql.org; Mon, 16 Jul 2018 14:39:33 +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 w6GEdQ3b020437; Mon, 16 Jul 2018 10:39:26 -0400 From: Tom Lane To: Andres Freund cc: Michael Paquier , Justin Pryzby , PostgreSQL Hackers Subject: Re: ENOSPC FailedAssertion("!(RefCountErrors == 0)" In-reply-to: <20180716131337.usestwjviwwocpyz@alap3.anarazel.de> References: <20180627233939.GA10276@telsasoft.com> <20180628020432.GB11054@paquier.xyz> <7317.1531694923@sss.pgh.pa.us> <20180716131337.usestwjviwwocpyz@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Mon, 16 Jul 2018 06:13:37 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20435.1531751966.1@sss.pgh.pa.us> Date: Mon, 16 Jul 2018 10:39:26 -0400 Message-ID: <20436.1531751966@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-07-15 18:48:43 -0400, Tom Lane wrote: >> So basically, WAL replay hits an error while holding a buffer pin, and >> nothing is done to release the buffer pin, but AtProcExit_Buffers thinks >> something should have been done. > I think there's a few other cases where we hit this. I've seen something > similar from inside checkpointer / BufferSync(). I'd be surprised if > bgwriter couldn't be triggered into the same. Hm, yeah, on reflection it's pretty obvious that those are hazard cases. > I'm pretty sure that we do *not* force a panic on all nonzero-exit-code > cases for other subprocesses. That's my recollection as well -- mostly, we just start a new one. So I said I didn't want to do extra work on this, but I am looking into fixing it by having these aux process types run a ResourceOwner that can be told to clean up any open buffer pins at exit. We could be sure the coverage is complete by dint of removing the special-case code in resowner.c that allows buffer pins to be taken with no active resowner. Then CheckForBufferLeaks can be left as-is, ie something we do only in assert builds. regards, tom lane