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 1g4V31-00052S-7L for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Sep 2018 17:53:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4V2v-0004t0-NY for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Sep 2018 17:53:21 +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 1g4V2v-0004st-G8 for pgsql-hackers@lists.postgresql.org; Mon, 24 Sep 2018 17:53:21 +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 1g4V2n-0000dl-Cc for pgsql-hackers@lists.postgresql.org; Mon, 24 Sep 2018 17:53:20 +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 w8OHr5Z5014560; Mon, 24 Sep 2018 13:53:05 -0400 From: Tom Lane To: Noah Misch cc: Heath Lord , Andres Freund , Thomas Munro , Stephen Frost , PostgreSQL Hackers Subject: Re: "could not reattach to shared memory" on buildfarm member dory In-reply-to: <20180819020007.GD3795674@rfd.leadboat.com> References: <25495.1524517820@sss.pgh.pa.us> <20180423231855.GK27724@tamriel.snowman.net> <20180424070646.GA2693533@rfd.leadboat.com> <17897.1525108069@sss.pgh.pa.us> <29823.1525132900@sss.pgh.pa.us> <20180501002419.onmikldoe2ssjauq@alap3.anarazel.de> <18056.1525148010@sss.pgh.pa.us> <22096.1525188710@sss.pgh.pa.us> <20180819020007.GD3795674@rfd.leadboat.com> Comments: In-reply-to Noah Misch message dated "Sat, 18 Aug 2018 19:00:07 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14553.1537811585.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 24 Sep 2018 13:53:05 -0400 Message-ID: <14554.1537811585@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Noah Misch writes: > On Tue, May 01, 2018 at 11:31:50AM -0400, Tom Lane wrote: >> Well, at this point the only thing that's entirely clear is that none >> of the ideas I had work. I think we are going to be forced to pursue >> Noah's idea of doing an end-to-end retry. Somebody else will need to >> take point on that; I lack a Windows environment and have already done >> a lot more blind patch-pushing than I like in this effort. > Having tried this, I find a choice between performance and complexity. = Both > of my designs use proc_exit(4) to indicate failure to reattach. The sim= pler, > slower design has WIN32 internal_forkexec() block until the child report= s (via > SetEvent()) that it reattached to shared memory. This caused a fivefold > reduction in process creation performance[1]. Ouch. > The less-simple, faster design > stashes the Port structure and retry count in the BackendList entry, whi= ch > reaper() uses to retry the fork upon seeing status 4. Notably, this req= uires > new code for regular backends, for bgworkers, and for others. Messy as that is, I think actually the worse problem with it is: > In this proof of concept, the > postmaster does not close its copy of a backend socket until the backend > exits. That seems unworkable because it would interfere with detection of client connection drops. But since you say this is just a POC, maybe you intended to fix that? It'd probably be all right for the postmaster to hold onto the socket until the new backend reports successful attach, using the same signaling mechanism you had in mind for the other way. Overall, I agree that neither of these approaches are exactly attractive. We're paying a heck of a lot of performance or complexity to solve a problem that shouldn't even be there, and that we don't understand well. In particular, the theory that some privileged code is injecting a thread into every new process doesn't square with my results at https://www.postgresql.org/message-id/15345.1525145612%40sss.pgh.pa.us I think our best course of action at this point is to do nothing until we have a clearer understanding of what's actually happening on dory. Perhaps such understanding will yield an idea for a less painful fix. regards, tom lane