Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5jK4-0004mo-A8 for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Sep 2018 03:20:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5jK2-0007hC-6g for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Sep 2018 03:20:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5jK1-0007h5-T6 for pgsql-bugs@lists.postgresql.org; Fri, 28 Sep 2018 03:20:06 +0000 Received: from sraihb2.sra.co.jp ([202.32.10.6]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5jJz-0001VU-1y for pgsql-bugs@lists.postgresql.org; Fri, 28 Sep 2018 03:20:04 +0000 Received: from srascf.sra.co.jp (srascf [133.137.8.80]) by sraihb2.sra.co.jp (Postfix) with ESMTP id 17CA42A15AC for ; Fri, 28 Sep 2018 12:20:01 +0900 (JST) Received: from srascb.sra.co.jp (unknown [133.137.8.65]) by srascf.sra.co.jp with smtp id 7fe5_00d5_b02bfcf5_f265_4736_8975_e2301f0d1e0a; Fri, 28 Sep 2018 12:20:00 +0900 Received: from sranhm.sra.co.jp (osspc25 [133.137.174.97]) by srascb.sra.co.jp (Postfix) with ESMTP id E5AC92D6942 for ; Fri, 28 Sep 2018 12:20:00 +0900 (JST) Received: from harukat-PC (dhcp-175-150.sra.co.jp [133.137.175.150]) by sranhm.sra.co.jp (Postfix) with SMTP id C39DCA10AF; Fri, 28 Sep 2018 12:20:00 +0900 (JST) Date: Fri, 28 Sep 2018 12:20:03 +0900 From: TAKATSUKA Haruka To: Michael Paquier Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15402: Hot standby server with archive_mode=on keeps initial WAL segments Message-Id: <20180928122003.fccf29e4b18e1578eea81967@sraoss.co.jp> In-Reply-To: <20180927044430.GP1659@paquier.xyz> References: <15402-a453c90ed4cf88b2@postgresql.org> <20180926035205.GJ1659@paquier.xyz> <20180926133640.99bfbc7ea82f71aa91a02c11@sraoss.co.jp> <20180926141236.160707712aea82341f01b03f@sraoss.co.jp> <20180927044430.GP1659@paquier.xyz> Organization: SRA OSS, Inc. X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.23; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Michael, On Thu, 27 Sep 2018 13:44:30 +0900 Michael Paquier wrote: > On Wed, Sep 26, 2018 at 02:12:36PM +0900, TAKATSUKA Haruka wrote: > > I think is it natural that some segments are not archived when you > > switch archive_mode back-and-forth. > > > > I also think a fix to prevent generating .ready file at hot standby > > server in this case is better. I don't have a concrete idea to do so now. > > I looked at this problem, and I completely agree. From what I can see, > the restart point run on the standby creates a .ready file for the > oldest segment because there were no .done file present in it, so the > checkpointer thinks that it should mark the file with .ready, and then > makes it ready for archiving, which is never going to happen with > archive_mode = on. All the newer segments are already marked with > .done, so they are getting recycled correctly. > > Your patch is not completely correct though, as the origin of the > problem comes from XLogArchiveCheckDone(), which should be made more > solid depending on the archive mode used. The solution attached > actually fixes a second bug, which is less annoying by the way, as past > backup history files may stay behind on standbys. I looked at all the > code paths of XLogArchivingActive() and that's the only problem I can > see. I fixed only RemoveOldXlogFiles() in my patch because merely I wasn't sure that keeping an old history file is a bug behavir. > In guc.c, SHOW archive_command would print as "(disabled)" on > standbys even if archive_mode = on, but we lived with this behavior for > ages. The user can understand that archiving is enabled only on a > primary this way when looking at a standby, so that should not be > changed. > > Takatsuka-san, what do you think? I think it is not necessary to change though it is a somewhat mistakable feature. Thanks, Haruka Takatsuka