Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f63bE-0003rS-3y for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Apr 2018 00:26:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f63bC-00040N-El for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Apr 2018 00:26:54 +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 1f63bC-00040C-7I for pgsql-hackers@lists.postgresql.org; Wed, 11 Apr 2018 00:26:54 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f63b4-0006GT-QD for pgsql-hackers@postgresql.org; Wed, 11 Apr 2018 00:26:53 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5EDA920CF2; Tue, 10 Apr 2018 20:26:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 10 Apr 2018 20:26:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=9GYyWk1Eic3rWwcPFgQF4K3AuOaBgJOSrQmFRumfsEM=; b=EWpY//ye JaiqjxhqL19x1oOig81Zfiyh792uA2eMbKGoDaaV2OmzNvlMixQZERR3BjpC+13P F6AU9V0CKtPJuhsSJjHjXNYuNPZwJVKEkCiIrj/Cm5TQQf7w69riDSyVN6A+Ozpm hGODA/I0s23AHRWewoUan+o2XVNK04pALc2pQ1AeIZt85Fy+tUSGzPJ0PBB11NN3 PixCdYXrYnEmNbbzdaHQZzgCBdI5z/+zenhjJC062YcmAvFSeeju/XayP0Au99uK kKEAQJbuRQBihB4se54U/1liLB58IqsGgmPX5urAxUAIgRhwFPjPsw6ad8Z5u+pq 7ZqlIovxQySIvQ== 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=fm2; bh=9GYyWk1Eic3rWwcPFgQF4K3AuOaBg JOSrQmFRumfsEM=; b=nHnHFNCQBJYa+67zxWvhah9hdk+cIVYIHzLMDYv94TDcH g5zinEYg1liAAGlLvL4FtXnCjz4DyK1hvFCnnzX7C+d06VFeyLGhdu9sAgkP9ibG AFG54pIDMxuwIgOm0NYuuFRva9diTp6lfNREoyPv3NTwJL+dXVwjOSzrZZ92Ppyn zGMywy4hMJ10uYmyDyyIowDkO0DKgrosHc/Bo0nDqUFkyxBZLenzaD2cA8ksVYy8 0RruBx0Pe5JhfQicVDZZDZM4N2VZU5kyH7gZVd/VbtEEZAgOxvnlVL4Pj7oacSQI 2254ZmUO6DAmSOd5rYhi70OAl+a7vHcRbbsCQnXQw== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id EE389E4394; Tue, 10 Apr 2018 20:26:44 -0400 (EDT) Date: Tue, 10 Apr 2018 17:26:43 -0700 From: Andres Freund To: Thomas Munro Cc: Marco Pfatschbacher , Pg Hackers Subject: Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process Message-ID: <20180411002643.6buofht4ranhei7k@alap3.anarazel.de> References: <20160915135755.GC19008@genua.de> <20160915192616.f2yq4wtltnlhjw3h@alap3.anarazel.de> <20160916075547.GC15576@genua.de> <20160916182339.2qe2bj3zgk6zfkgk@alap3.anarazel.de> <20160919232606.jdhup2qsrgnjq4xc@alap3.anarazel.de> <20180411000327.7t4r7bckeqyo3jju@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2018-04-11 12:17:14 +1200, Thomas Munro wrote: > I arrived at this idea via the realisation that the closest thing to > prctl(PR_SET_PDEATHSIG) on BSD-family systems today is > please-tell-my-kqueue-if-this-process-dies. It so happens that my > kqueue patch already uses that instead of the pipe to detect > postmaster death. The only problem is that you have to ask it, by > calling it kevent(). In a busy loop like those two, where there is no > other kind of waiting going on, you could do that by calling kevent() > with timeout = 0 to check the queue. Which is not cheap. > You could probably figure out a way to hide the > prctl(PR_SET_PDEATHSIG)-based approach inside the WaitEventSet code, > with a fast path that doesn't make any system calls if the only event > registered is postmaster death (you can just check the global variable > set by your signal handler). But I guess you wouldn't like the extra > function call so I guess you'd prefer to check the global variable > directly in the busy loop, in builds that have > prctl(PR_SET_PDEATHSIG). Yea, I'd really want this to be a inline function of the style static inline bool PostmasterIsAlive(void) { if (!postmaster_possibly_dead) return true; return PostmasterIsAliveInternal(); } I do not like the WES alternative because a special cased "just postmaster death" WES seems to have absolutely no advantage over a faster PostmasterIsAlive(). And using WES seems to make a cheap check like the above significantly more complicated. Greetings, Andres Freund