Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipEtq-0006t6-It for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jan 2020 17:13:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipEto-0007Qa-Lc for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jan 2020 17:13:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipEto-0007Pl-9B for pgsql-bugs@lists.postgresql.org; Wed, 08 Jan 2020 17:13:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ipEtl-0005Mu-Dh for pgsql-bugs@lists.postgresql.org; Wed, 08 Jan 2020 17:13:38 +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 008HDZA6009846; Wed, 8 Jan 2020 12:13:35 -0500 From: Tom Lane To: git@rmr.ninja cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16199: pg_restore stuck on interrupts In-reply-to: <16199-cb2f121146a96f9b@postgresql.org> References: <16199-cb2f121146a96f9b@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 08 Jan 2020 16:17:57 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9844.1578503615.1@sss.pgh.pa.us> Date: Wed, 08 Jan 2020 12:13:35 -0500 Message-ID: <9845.1578503615@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > We are seeing stuck pg_restore processes in several of our CI servers, both > with PG10 (10.2) and PG11 (11.5). You didn't actually say, but you must be interrupting parallel restores with SIGINT or the like? > I have a some extra processes with the same issue (7 full stacks out of 20, > the others are garbage) and, from what I see, they all have in common that > the process has received a signal while it was doing a memory operation, > either a malloc or a free: Yeah. Ugh :-( > I think if would be safer to use a similar approach to other processes, that > is use the handler to only enable a global flag and check that in the main > loop, but I'm having a hard time locating what the proper place to check the > flag would be. I think the odds of that being an improvement are minimal --- you'd be trading a risk of failure during exit for a risk of not exiting (in any timely fashion) in the first place. sigTermHandler tries to be safe to run in a signal context, but I'm afraid we didn't think hard about what exit() might call. The way I'd be inclined to fix this is to call _exit() instead of exit(), and the heck with what any atexit handlers think. Can you try that and see if it improves matters for you? regards, tom lane