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 1kcSn5-0008Mh-4n for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Nov 2020 12:30:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kcSn4-0002y2-4o for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Nov 2020 12:30:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcSn3-0002wH-Rx for pgsql-hackers@lists.postgresql.org; Tue, 10 Nov 2020 12:30:25 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kcSmz-0005QN-Lm for pgsql-hackers@postgresql.org; Tue, 10 Nov 2020 12:30:25 +0000 Received: by mail-pf1-x435.google.com with SMTP id c66so5581208pfa.4 for ; Tue, 10 Nov 2020 04:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xcypH+0frX9DcDyWMXMzzRcriShaxjXmQOorWa6z4R0=; b=LMAPfY/RHJPyqyo8AmzMML58hbPnZ8qx826Lz7kcFXSb65UOGFzq6xU84PA5gF/Oe1 jo/PA5X9kGaHR1KTUVmJcSAH5dLNVOOo2r4np/du/2+xDI2qo2QNIWF5Ggkp2aFdZvn1 azeXmIwZWwIRoxjsYA3xd1mElPO3uk6CXYaoivP2vRhpg7CfEGO/UBv5carWQcYMcOIM q/k1X42+vYNb0l/0bZwL6QbCNPkAZWoSeeX6BEu+OlcLDfOqibQJC5R9xl01EGgn+y/I GbTivWJa1isOnsFewEZlGI94Dc5wayzbUGZ/5qHp6Yp2NW80SeIBQbzxmh5l5A4TkSt2 0GNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xcypH+0frX9DcDyWMXMzzRcriShaxjXmQOorWa6z4R0=; b=n35vlPLCWaf+zly02jXuBDoQYyFrGv4oQOtXMV1AB4kbZMJHezERIHzFKpKs/dqqIP IrM63j+YnZjtG+kPi/kFQ2mZdGQA7EVHZQf6OcSB0DJyLe+uP8/RsQ8XdtZPm1MfbOYr B96En0YFJYv54LCg1Go1nCG8SV9nQl7NADWBStgs/+Q+jrWfgsQA4Ni07J332OiaHpHc fWhF82t/WixChc9D2bG7akUFKjQKDOvvQgjA0AskRan+zJM4R+5HJfwMqq4nMMcJH5vA 4j+a/qFgVK4cNB0PXZYVYZeXI/jztaamfm6bshLvD+N7k8ORsFx6qhjV4kewNFjfFjXJ 29BQ== X-Gm-Message-State: AOAM532mV1lvKRvPBu4dX+s9/n7hYdYRqFgjIIrnThcXhN/EaCW8U1JW onPp3e4g5CgKA2UbE20jD9aXwLY5fwmdSPz6QeE= X-Google-Smtp-Source: ABdhPJzysUiSJ4R4zlbwVtyuCCCix25AH7apbODV991gYXRFtm68RvmYj+tvA8yYSh7bBfEzsPf2zxvtXuYLQlJOoZ0= X-Received: by 2002:a17:90a:4802:: with SMTP id a2mr5099976pjh.22.1605011419184; Tue, 10 Nov 2020 04:30:19 -0800 (PST) MIME-Version: 1.0 References: <20201105.121206.819769369617763972.horikyota.ntt@gmail.com> <20201110.161740.1341818036035711165.horikyota.ntt@gmail.com> In-Reply-To: From: Bharath Rupireddy Date: Tue, 10 Nov 2020 18:00:07 +0530 Message-ID: Subject: Re: Use standard SIGHUP and SIGTERM handlers in autoprewarm module To: Fujii Masao Cc: Kyotaro Horiguchi , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com