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 1ksKBX-0005Bt-Hb for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Dec 2020 06:33: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 1ksKBV-0004Xf-IX for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Dec 2020 06:33:13 +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 1ksKBV-0004XY-Bn for pgsql-hackers@lists.postgresql.org; Thu, 24 Dec 2020 06:33:13 +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 1ksKBR-0000Pk-F0 for pgsql-hackers@lists.postgresql.org; Thu, 24 Dec 2020 06:33:12 +0000 Received: from hnk.local (p2430165-ipbf2730funabasi.chiba.ocn.ne.jp [122.24.66.165]) by oss.nttdata.com (Postfix) with ESMTPSA id A216F627A3; Thu, 24 Dec 2020 15:33:04 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: A failure of standby to follow timeline switch To: Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org References: <20201209.174314.282492377848029776.horikyota.ntt@gmail.com> From: Fujii Masao Message-ID: <697adab0-a3fe-e1cb-436b-3a8eaa9a2266@oss.nttdata.com> Date: Thu, 24 Dec 2020 15:33:04 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20201209.174314.282492377848029776.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=windows-1252; 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/12/09 17:43, Kyotaro Horiguchi wrote: > Hello. > > We found a behavioral change (which seems to be a bug) in recovery at > PG13. > > The following steps might seem somewhat strange but the replication > code deliberately cope with the case. This is a sequense seen while > operating a HA cluseter using Pacemaker. > > - Run initdb to create a primary. > - Set archive_mode=on on the primary. > - Start the primary. > > - Create a standby using pg_basebackup from the primary. > - Stop the standby. > - Stop the primary. > > - Put stnadby.signal to the primary then start it. > - Promote the primary. > > - Start the standby. > > > Until PG12, the parimary signals end-of-timeline to the standby and > switches to the next timeline. Since PG13, that doesn't happen and > the standby continues to request for the segment of the older > timeline, which no longer exists. > > FATAL: could not receive data from WAL stream: ERROR: requested WAL segment 000000010000000000000003 has already been removed > > It is because WalSndSegmentOpen() can fail to detect a timeline switch > on a historic timeline, due to use of a wrong variable to check > that. It is using state->seg.ws_segno but it seems to be a thinko when > the code around was refactored in 709d003fbd. > > The first patch detects the wrong behavior. The second small patch > fixes it. Thanks for reporting this! This looks like a bug. When I applied two patches in the master branch and ran "make check-world", I got the following error. ============== creating database "contrib_regression" ============== # Looks like you planned 37 tests but ran 36. # Looks like your test exited with 255 just after 36. t/001_stream_rep.pl .................. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 1/37 subtests ... Test Summary Report ------------------- t/001_stream_rep.pl (Wstat: 65280 Tests: 36 Failed: 0) Non-zero exit status: 255 Parse errors: Bad plan. You planned 37 tests but ran 36. Files=21, Tests=239, 302 wallclock secs ( 0.10 usr 0.05 sys + 41.69 cusr 39.84 csys = 81.68 CPU) Result: FAIL make[2]: *** [check] Error 1 make[1]: *** [check-recovery-recurse] Error 2 make[1]: *** Waiting for unfinished jobs.... t/070_dropuser.pl ......... ok Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION