Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFWAj-0005IW-RF for pgsql-general@arkaria.postgresql.org; Fri, 17 Nov 2017 02:14: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 1eFWAi-0005Jp-Q1 for pgsql-general@arkaria.postgresql.org; Fri, 17 Nov 2017 02:14: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 1eFWAh-0005II-Ng for pgsql-general@postgresql.org; Fri, 17 Nov 2017 02:14:23 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eFWAe-00035g-He for pgsql-general@postgresql.org; Fri, 17 Nov 2017 02:14:23 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E8BE020833; Thu, 16 Nov 2017 21:14:18 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Thu, 16 Nov 2017 21:14:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=fJlwlRG2q3LAFjo4wUp3Qua+1lOzC UmOM10qkVdtCZs=; b=bNwiMOT6sRfvpygjYPjZqEkAEILITkxUxZ2BhEXbRffqb PTuIi2WR5jg7oE2d8Q4DCejlyZ1inUQ8p2gLVmq7kHKClkIYqVt8lIdQkpPtMmVk H+HCYeuDnbG1jg/9eSf4RVJU+mDk0aRN2UgvzVSUbgKoNaUXBa3riIfWas4l1OaY 5uo/WPA7VmDvxtVtd9LAlXTjudbbJbFXe24erJv9S6ox+9bHrYB3hAXIv5pPqHgv dT1e8ZgbRl0/XcXH3HX7c4gvfgw3ydamX6Emi9J61KA2s8ecjal2lHtEFbZM7XPm tqEraBotlKnoRDz3BlJHZx5GqF+cGaVWNEOoEwBVg== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 5DACA7FA97; Thu, 16 Nov 2017 21:14:18 -0500 (EST) Date: Thu, 16 Nov 2017 18:14:17 -0800 From: Andres Freund To: Michael Paquier Cc: Tom Lane , David Pacheco , PostgreSQL mailing lists Subject: Re: postmaster deadlock while logging after syslogger exited Message-ID: <20171117021417.7wg3qlzhvmijw4b3@alap3.anarazel.de> References: <19239.1510000503@sss.pgh.pa.us> <20171117015040.m36ovf5dqtg3star@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 2017-11-17 11:09:56 +0900, Michael Paquier wrote: > On Fri, Nov 17, 2017 at 10:50 AM, Andres Freund wrote: > > On 2017-11-06 15:35:03 -0500, Tom Lane wrote: > >> David Pacheco writes: > >> > I ran into what appears to be a deadlock in the logging subsystem. It > >> > looks like what happened was that the syslogger process exited because it > >> > ran out of memory. But before the postmaster got a chance to handle the > >> > SIGCLD to restart it, it handled a SIGUSR1 to start an autovacuum worker. > >> > That also failed, and the postmaster went to log a message about it, but > >> > it's blocked on the pipe that's normally connected to the syslogger, > >> > presumably because the pipe is full because the syslogger is gone and > >> > hasn't read from it. > >> > >> Ugh. > > > > I'm somewhat inclined to say that one has to live with this if the > > system is so resource constrainted that processes barely using memory > > get killed. > > > > We could work around a situation like that if we made postmaster use a > > *different* pipe as stderr than the one we're handing to normal > > backends. If postmaster created a new pipe and closed the read end > > whenever forking a syslogger, we should get EPIPEs when writing after > > syslogger died and could fall back to proper stderr or such. > > I don't have the code on top of my mind, but isn't a custom fd causing > a small penalty Sure, there's some minor overhead because every process would need to close another fd after forking. > when redirection_done is switched to true because the first process > generating a message to the syslogger pipe needs to open it first if > not done yet? I can't follow. The syslogger pipe is created when the first syslogger is started (before it's forked!). Which happens before other processes are created, because they all need to inherit that file descriptor. > So you'd need proper locking to save from race conditions. I completely fail to see why this'd be the case. All I'm talking about is using another pipe between syslogger and postmaster than between other-processes and syslogger. Greetings, Andres Freund -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general