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 1kXkA9-00024B-By for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Oct 2020 12:02:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXkA8-0002Ag-CB for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Oct 2020 12:02:44 +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 1kXkA8-0002AO-0J for pgsql-hackers@lists.postgresql.org; Wed, 28 Oct 2020 12:02:44 +0000 Received: from forward500o.mail.yandex.net ([2a02:6b8:0:1a2d::610]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXkA3-0003Jb-Bc for pgsql-hackers@postgresql.org; Wed, 28 Oct 2020 12:02:42 +0000 Received: from mxback6q.mail.yandex.net (mxback6q.mail.yandex.net [IPv6:2a02:6b8:c0e:42:0:640:9de5:975f]) by forward500o.mail.yandex.net (Yandex) with ESMTP id 6424D60815; Wed, 28 Oct 2020 15:02:34 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback6q.mail.yandex.net (mxback/Yandex) with ESMTP id BjOYssSXMg-2X9iB2G3; Wed, 28 Oct 2020 15:02:33 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zsrv.org; s=mail; t=1603886553; bh=NBgvH5zW4c11K2A31N29oe3i++93VDIvmk6W6y3XJ5Y=; h=Message-Id:Cc:Subject:In-Reply-To:Date:References:To:From; b=OLyMv5234bqa0ytbdqk2lCV43eFsS8NRLzEKIFzdThVjCyGQcZC4QgJoiZ2yKSLv2 KHkNwL4rkj/BrmhARu8LKatSlFzhTIl4yn8O3gFLbDHkj3dCVTXwk69Rkvdb49VSxh m3wKRKIK5szZ283RmT5lCek2izvZg/PoVNosWuys= Authentication-Results: mxback6q.mail.yandex.net; dkim=pass header.i=@zsrv.org Received: by vla1-d0568624e250.qloud-c.yandex.net with HTTP; Wed, 28 Oct 2020 15:02:33 +0300 From: Sergei Kornilov To: Kyotaro Horiguchi , "a.lubennikova@postgrespro.ru" Cc: "robertmhaas@gmail.com" , "michael@paquier.xyz" , "andres@anarazel.de" , "peter.eisentraut@2ndquadrant.com" , "pgsql-hackers@postgresql.org" In-Reply-To: <20201022.110026.524650499365127827.horikyota.ntt@gmail.com> References: <20200809052149.GB17986@paquier.xyz> <1741c40b-73e3-133b-77e6-05ebc7bf3c0f@postgrespro.ru> <20201022.110026.524650499365127827.horikyota.ntt@gmail.com> Subject: Re: Allow some recovery parameters to be changed with reload MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Wed, 28 Oct 2020 15:02:33 +0300 Message-Id: <4920201603879284@mail.yandex.ru> Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Sorry for late response. >>  > ... but what's the corresponding hazard here, exactly? It doesn't seem >>  > that there's any way in which the decision one process makes affects >>  > the decision the other process makes. There's still a race condition: >>  > it's possible for a walsender >>  Did you mean walreceiver here? > > It's logical walsender. restore_command is used within > logical_read_xlog_page() via XLogReadDetermineTimeline(). Still have no idea what's the corresponding hazard here. >>  > to use the old restore_command after the >>  > startup process had already used the new one, or the other way around. >>  > However, it doesn't seem like that should confuse anything inside the >>  > server, and therefore I'm not sure we need to code around it. >>  I came up with following scenario. Let's say we have xlog files 1,2,3 >>  in dir1 and files 4,5 in dir2. If startup process had only handled >>  files 1 and 2, before we switched restore_command from reading dir1 to >>  reading dir2, it will fail to find next file. IIUC, it will assume >>  that recovery is done, start server and walreceiver. The walreceiver >>  will fail as well. I don't know, how realistic is this case, though. > > That operation is somewhat bogus, if the server is not in standby > mode. In standby mode, startup waits for the next segment safely. I think it's pilot error. It is already possible to change anything in restore_command by wrapping real command into some script: > restore_command = '/bin/restore_wal.sh "%f" "%p"' And one can simple replace this file with something else with different logic. Or even by using some command with separate own settings. Real world example ( https://github.com/wal-g/wal-g ): > restore_command = '. /etc/wal-g/WALG_AWS_ENV; wal-g wal-fetch "%f" "%p"' And it is possible to change the real WAL source in ENV script without changing the restore_command. We can't track this, so I not see new issues here. >>  Sergey, could you please attach this thread to the upcoming CF, if >>  you're going to continue working on it. Sure, I created one: https://commitfest.postgresql.org/30/2802/ >>  - How will it interact with possible future optimizations of archive >>  - restore? For example, WAL prefetch [1]. Shouldn't we ask the author of such a patch and not me? In particular, does this patch rely on the restore_command not being changed? Probably some form of synchronisation would be neccesary in infrastructure for parallel executing restore commands. On / off handling of restore_command will most likely be required. I did not review this patch. regards, Sergei