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 1kIxYd-00019q-5m for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2020 17:18:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIxYc-0002sF-2Q for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2020 17:18:54 +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 1kIxYb-0002s8-Rb for pgsql-hackers@lists.postgresql.org; Thu, 17 Sep 2020 17:18:53 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIxYZ-0005GL-FU for pgsql-hackers@lists.postgresql.org; Thu, 17 Sep 2020 17:18:53 +0000 Received: from hnk.local (p2368131-ipbf2226funabasi.chiba.ocn.ne.jp [114.177.250.131]) by oss.nttdata.com (Postfix) with ESMTPSA id 5AFE8623AA; Fri, 18 Sep 2020 02:18:46 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: history file on replica and double switchover From: Fujii Masao To: Anastasia Lubennikova , Grigory Smolkin , Postgres hackers References: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru> <4f7379a6-b196-70fe-708d-84a2672b3c22@oss.nttdata.com> Message-ID: <2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com> Date: Fri, 18 Sep 2020 02:18:45 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <4f7379a6-b196-70fe-708d-84a2672b3c22@oss.nttdata.com> Content-Type: multipart/mixed; boundary="------------E83FA1B12ED97575110DD8FA" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------E83FA1B12ED97575110DD8FA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2020/09/04 13:53, Fujii Masao wrote: > > > On 2020/09/04 8:29, Anastasia Lubennikova wrote: >> On 27.08.2020 16:02, Grigory Smolkin wrote: >>> Hello! >>> >>> I`ve noticed, that when running switchover replica to master and back to replica, new history file is streamed to replica, but not archived, >>> which is not great, because it breaks PITR if archiving is running on replica. The fix looks trivial. >>> Bash script to reproduce the problem and patch are attached. >>> >> Thanks for the report. I agree that it looks like a bug. > > +1 > > +            /* Mark history file as ready for archiving */ > +            if (XLogArchiveMode != ARCHIVE_MODE_OFF) > +                XLogArchiveNotify(fname); > > I agree that history file should be archived in the standby when > archive_mode=always. But why do we need to do when archive_mode=on? > I'm just concerned about the case where the primary and standby > have the shared archive area, and archive_mode is on. So I updated the patch so that walreceiver marks the streamed history file as ready for archiving only when archive_mode=always. Patch attached. Thought? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION --------------E83FA1B12ED97575110DD8FA Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="history_replica_v2.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="history_replica_v2.patch" ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL3dhbHJlY2VpdmVyLmMgYi9z cmMvYmFja2VuZC9yZXBsaWNhdGlvbi93YWxyZWNlaXZlci5jCmluZGV4IDE3ZjFhNDlmODcu LjMyNjkzYzU2ZGIgMTAwNjQ0Ci0tLSBhL3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL3dhbHJl Y2VpdmVyLmMKKysrIGIvc3JjL2JhY2tlbmQvcmVwbGljYXRpb24vd2FscmVjZWl2ZXIuYwpA QCAtNzU4LDYgKzc1OCwxMCBAQCBXYWxSY3ZGZXRjaFRpbWVMaW5lSGlzdG9yeUZpbGVzKFRp bWVMaW5lSUQgZmlyc3QsIFRpbWVMaW5lSUQgbGFzdCkKIAkJCSAqLwogCQkJd3JpdGVUaW1l TGluZUhpc3RvcnlGaWxlKHRsaSwgY29udGVudCwgbGVuKTsKIAorCQkJLyogTWFyayBoaXN0 b3J5IGZpbGUgYXMgcmVhZHkgZm9yIGFyY2hpdmluZyAqLworCQkJaWYgKFhMb2dBcmNoaXZl TW9kZSA9PSBBUkNISVZFX01PREVfQUxXQVlTKQorCQkJCVhMb2dBcmNoaXZlTm90aWZ5KGZu YW1lKTsKKwogCQkJcGZyZWUoZm5hbWUpOwogCQkJcGZyZWUoY29udGVudCk7CiAJCX0K --------------E83FA1B12ED97575110DD8FA--