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 1kxy45-0007X7-OL for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Jan 2021 20:08:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kxy42-0007bw-G0 for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Jan 2021 20:08:50 +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 1kxy42-0007bn-8s for pgsql-hackers@lists.postgresql.org; Fri, 08 Jan 2021 20:08:50 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxy3z-0007G7-87 for pgsql-hackers@lists.postgresql.org; Fri, 08 Jan 2021 20:08:49 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 15D2F5C02D1; Fri, 8 Jan 2021 15:08:46 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 08 Jan 2021 15:08:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=fsTIMl9xWAyOQCxaJNUn4H1AoJwmr3KgDDTPtavz/C8=; b=rfgeRc/2 jK0jZuCEM/D9HhI9N5RgYLEfiMzq89ohuHKzPbyruoqGpj2187CG4jNB4IwIkwJp 1gI5cr+kRpwrNMxyMmcXn4uZ37waBgDuTTM1D6yjvQXU0hYH//yZFAje095B8Jxt sWBQ5c8lY38YHbE1HH4CeOPnDtL8ed7VLAUzpYWYELTe2+Txs3gMJ3lQ3rti4KfI U2QZ19pmaoBXLfCom1pYBMq23gFhdl0OftvI0sjEh9MNQfh3nQr4a8Ca2PaDnvYa PGuIZCHgTdNHMFjZIOCV8qJDpcYu3htnPpKaSPV9RbJRIlyj2/PvfFZFIwQ44SXI oDRxJ4W6sux9SQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdeghedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugfgjggfsehtke ertddtredunecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeeufffhjeeiue euffegvddukeegledtveeivdeiueefieeivefgteehueefteehvdenucfkphepudeltddr leehrdduledrudejjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.177]) by mail.messagingengine.com (Postfix) with ESMTPA id 2FCA01080057; Fri, 8 Jan 2021 15:08:45 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 06AA92A0AE3; Fri, 8 Jan 2021 17:08:43 -0300 (-03) Date: Fri, 8 Jan 2021 17:08:43 -0300 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org Subject: Re: A failure of standby to follow timeline switch Message-ID: <20210108200843.GA26309@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210107.163236.776031941315368203.horikyota.ntt@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Masao-san: Are you intending to act as committer for these? Since the bug is mine I can look into it, but since you already did all the reviewing work, I'm good with you giving it the final push. 0001 looks good to me; let's get that one committed quickly so that we can focus on the interesting stuff. While the implementation of find_in_log is quite dumb (not this patch's fault), it seems sufficient to deal with small log files. We can improve the implementation later, if needed, but we have to get the API right on the first try. 0003: The fix looks good to me. I verified that the test fails without the fix, and it passes with the fix. The test added in 0002 is a bit optimistic regarding timing, as well as potentially slow; it loops 1000 times and sleeps 100 milliseconds each time. In a very slow server (valgrind or clobber_cache animals) this could not be sufficient time, while on fast servers it may end up waiting longer than needed. Maybe we can do something like this: for (my $i = 0 ; $i < 1000; $i++) { my $current_log_size = determine_current_log_size() if ($node_standby_3->find_in_log( "requested WAL segment [0-9A-F]+ has already been removed", $logstart)) { last; } elsif ($node_standby_3->find_in_log( "End of WAL reached on timeline", $logstart)) { $success = 1; last; } $logstart = $current_log_size; while (determine_current_log_size() == current_log_size) { usleep(10_000); # with a retry count? } } With test patch, make check PROVE_FLAGS="--timer" PROVE_TESTS=t/001_stream_rep.pl ok 6386 ms ( 0.00 usr 0.00 sys + 1.14 cusr 0.93 csys = 2.07 CPU) ok 6352 ms ( 0.00 usr 0.00 sys + 1.10 cusr 0.94 csys = 2.04 CPU) ok 6255 ms ( 0.01 usr 0.00 sys + 0.99 cusr 0.97 csys = 1.97 CPU) without test patch: ok 4954 ms ( 0.00 usr 0.00 sys + 0.71 cusr 0.64 csys = 1.35 CPU) ok 5033 ms ( 0.01 usr 0.00 sys + 0.71 cusr 0.73 csys = 1.45 CPU) ok 4991 ms ( 0.01 usr 0.00 sys + 0.73 cusr 0.59 csys = 1.33 CPU) -- Álvaro Herrera