Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1df6YT-0005hG-1g for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Aug 2017 15:36:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1df6YS-0005q0-HN for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Aug 2017 15:36:24 +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 1df6YR-0005og-9i for pgsql-hackers@postgresql.org; Tue, 08 Aug 2017 15:36:23 +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.84_2) (envelope-from ) id 1df6YO-0005kB-7j for pgsql-hackers@postgresql.org; Tue, 08 Aug 2017 15:36:22 +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 v78FaH2T004245; Tue, 8 Aug 2017 11:36:17 -0400 From: Tom Lane To: Jeevan Chalke cc: PostgreSQL Hackers Subject: Re: Server crash (FailedAssertion) due to catcache refcount mis-handling In-reply-to: References: Comments: In-reply-to Jeevan Chalke message dated "Tue, 08 Aug 2017 18:04:56 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4243.1502206577.1@sss.pgh.pa.us> Date: Tue, 08 Aug 2017 11:36:17 -0400 Message-ID: <4244.1502206577@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Jeevan Chalke writes: > We have observed a random server crash (FailedAssertion), while running few > tests at our end. Stack-trace is attached. > By looking at the stack-trace, and as discussed it with my team members; > what we have observed that in SearchCatCacheList(), we are incrementing > refcount and then decrementing it at the end. However for some reason, if > we are in TRY() block (where we increment the refcount), and hit with any > interrupt, we failed to decrement the refcount due to which later we get > assertion failure. Hm. So SearchCatCacheList has a PG_TRY block that is meant to release those refcounts, but if you hit the backend with a SIGTERM while it's in that function, control goes out through elog(FATAL) which doesn't execute the PG_CATCH cleanup. But it does do AbortTransaction which calls AtEOXact_CatCache, and that is expecting that all the cache refcounts have reached zero. We could respond to this by using PG_ENSURE_ERROR_CLEANUP there instead of plain PG_TRY. But I have an itchy feeling that there may be a lot of places with similar issues. Should we be revisiting the basic way that elog(FATAL) works, to make it less unlike elog(ERROR)? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers