Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLmEo-0005dg-At for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Mar 2014 04:18:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WLmEn-0000eG-Mu for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Mar 2014 04:18:21 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLmEm-0000e9-L9 for pgsql-bugs@postgresql.org; Fri, 07 Mar 2014 04:18:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLmEk-0000B0-7k for pgsql-bugs@postgresql.org; Fri, 07 Mar 2014 04:18:19 +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 s274IGiV000340; Thu, 6 Mar 2014 23:18:16 -0500 From: Tom Lane To: Peter LaDow cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9464: PANIC with 'failed to re-find shared lock object' In-reply-to: References: <20140307005623.1918.22473@wrigleys.postgresql.org> <31620.1394163148@sss.pgh.pa.us> Comments: In-reply-to Peter LaDow message dated "Thu, 06 Mar 2014 20:08:08 -0800" Date: Thu, 06 Mar 2014 23:18:16 -0500 Message-ID: <339.1394165896@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Peter LaDow writes: > On Thu, Mar 6, 2014 at 7:32 PM, Tom Lane wrote: >> on_exit_reset() in the first-level child would likely be a good idea. > Thanks for the tip! I tried it, and things are happy again. Hah, thanks for confirming the diagnosis. >> See atexit_callback in src/backend/storage/ipc/ipc.c: your first-level >> child is killing all the parent backend's shared-memory state when it >> does exit(). This is a safety feature we added at some point in the > Ah! Well, I guess I could use _exit() as well... > Any preference between the two? I don't think _exit() is a terribly good idea. Consider the possibility that some third-party library loaded into the backend has also established an atexit callback, and unlike what we did, that code does need to get control in a subprocess exit. I'm thinking we failed to consider this situation, and really the right thing is for atexit_callback() to defend itself against the case. One possibility is to do this: atexit_callback(void) { if (getpid() == MyProcPid) { /* Clean up everything that must be cleaned up */ /* ... too bad we don't know the real exit code ... */ proc_exit_prepare(-1); } } but that's pretty off-the-cuff, so I'm not sure if it still has failure modes. Could you try patching atexit_callback as above, and verify that it does what you want (with or without the on_exit_reset() in your extension)? regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs