Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kd4LH-0006R8-Si for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Nov 2020 04:36:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kd4LG-0001m0-RN for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Nov 2020 04:36:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kd4LG-0001lt-Jt for pgsql-hackers@lists.postgresql.org; Thu, 12 Nov 2020 04:36:14 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kd4LD-00025C-VT for pgsql-hackers@postgresql.org; Thu, 12 Nov 2020 04:36:13 +0000 Received: from hnk.local (p1295030-ipngn4902funabasi.chiba.ocn.ne.jp [153.166.85.30]) by oss.nttdata.com (Postfix) with ESMTPSA id 260C2622D3; Thu, 12 Nov 2020 13:36:08 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: Use standard SIGHUP and SIGTERM handlers in autoprewarm module To: Bharath Rupireddy Cc: Kyotaro Horiguchi , PostgreSQL-development References: <20201105.121206.819769369617763972.horikyota.ntt@gmail.com> <20201110.161740.1341818036035711165.horikyota.ntt@gmail.com> From: Fujii Masao Message-ID: <763d6041-49d3-96b2-d0ec-f56e676a5156@oss.nttdata.com> Date: Thu, 12 Nov 2020 13:36:07 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/11/10 21:30, Bharath Rupireddy wrote: > On Tue, Nov 10, 2020 at 3:04 PM Fujii Masao wrote: >> >>>> The main reason for having SetLatch() in >>>> SignalHandlerForConfigReload() is to wake up the calling process if >>>> waiting in WaitLatchOrSocket() or WaitLatch() and reload the new >>>> config file and use the reloaded config variables. Maybe we should >>>> give a thought on the scenarios in which the walreceiver process >>>> waits, and what happens in case the latch is set when SIGHUP is >>>> received. >>> >>> The difference is whether the config file is processed at the next >>> wakeup (by force-reply-request or SIGTERM) of walreceiver or >>> immediately. If server-reload happened frequently, say, several times >>> per second(?), we should consider to reduce the useless reloading, but >>> actually that's not the case. >> >> So, attached is the patch that makes walreceiver use both standard >> SIGTERM and SIGHUP handlers. Currently I've not found any actual >> issues by making walreceiver use standard SIGHUP handler, yet. >> > > I think it makes sense to replace WalRcv->latch with > MyProc->procLatch(as they point to the same latch) in the functions > that are called in the walreceiver process. However, we are using > walrcv->latch with spinlock, say in WalRcvForceReply() and > RequestXLogStreaming() both are called from the startup process. See > commit 45f9d08684, that made the access to the walreceiver's > latch(WalRcv->latch) by the other process(startup) spinlock protected > > And looks like, in general it's a standard practice to set latch to > wake up the process if waiting in case a SIGHUP signal is received and > reload the relevant config variables. > > Going by the above analysis, the v3 patch looks good to me. Thanks for the analysis! I pushed the patch. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION