Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vu2jP-0004WS-2Z for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Dec 2013 16:15:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vu2jN-000357-O9 for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Dec 2013 16:15:17 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vu2jM-00034m-Vk for pgsql-bugs@postgresql.org; Fri, 20 Dec 2013 16:15:17 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vu2jJ-0008RR-EQ for pgsql-bugs@postgresql.org; Fri, 20 Dec 2013 16:15:16 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 9F8F729E8A; Fri, 20 Dec 2013 08:15:12 -0800 (PST) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 9B9D2184DE; Fri, 20 Dec 2013 08:15:12 -0800 (PST) Received: from zcs-prod-ext-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 1AE86C005A; Fri, 20 Dec 2013 08:15:40 -0800 (PST) Received: from [192.168.43.149] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA; Fri, 20 Dec 2013 08:15:38 -0800 (PST) Message-ID: <52B46D0D.2070505@vmware.com> Date: Fri, 20 Dec 2013 18:15:09 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9 MIME-Version: 1.0 To: katsumata.tomonari@po.ntts.co.jp CC: pgsql-bugs@postgresql.org Subject: Re: BUG #8686: Standby could not restart. References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.4 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 12/19/2013 04:57 AM, katsumata.tomonari@po.ntts.co.jp wrote: > At first, I doubted the recovery state reached "consistent" before redo > starts. > And then I checked pg_control and related WAL. > The WAL sequence is like below. > > > WAL--(a)--(b)--(c)--(d)--(e)--> > ================================================ > (a) Latest checkpoint's REDO location > 1/783B230 > > > (b) hot_update > 1/7842010 > > > (c) truncate > 1/8E7E5C8 > > > (d) Latest checkpoint location > 1/8E7F0B0 > > > (e) Minimum recovery ending location > 1/8E7F110 > ================================================ > > >>From these things, I found it has happened with this scenario. > ---------- > (1) standby starting > (2) seeking checkpoint location 1/8E7F0B0 because backup_label is not > absecnt > (3) reachedConsistency is set to true at 1/8E7F110 in > CheckRecoveryConsistent > (4) redo start from 1/783B230 > (5) PANIC at 1/7842010 because reachedConsistency has set already and > operating against a block which will be truncated at (c). > ---------- > > At step(2), EndRecPtr is set to 1/8E7F110(next to 1/8E7F0B0), > so reachedConsistency is set to true at step(3). Yep. Thanks for a good explanation. > I think it's not need to increase EndRecPtr while seeking checkpoint > location. > I tried to revise it and this worked fine. Hmm. There's this comment in StartupXLOG, after reading the checkpoint record, but before reading the first record at REDO point: > /* > * Initialize shared replayEndRecPtr, lastReplayedEndRecPtr, and > * recoveryLastXTime. > * > * This is slightly confusing if we're starting from an online > * checkpoint; we've just read and replayed the checkpoint record, but > * we're going to start replay from its redo pointer, which precedes > * the location of the checkpoint record itself. So even though the > * last record we've replayed is indeed ReadRecPtr, we haven't > * replayed all the preceding records yet. That's OK for the current > * use of these variables. > */ > SpinLockAcquire(&xlogctl->info_lck); > xlogctl->replayEndRecPtr = ReadRecPtr; > xlogctl->lastReplayedEndRecPtr = EndRecPtr; > xlogctl->recoveryLastXTime = 0; > xlogctl->currentChunkStartTime = 0; > xlogctl->recoveryPause = false; > SpinLockRelease(&xlogctl->info_lck); I think we need to fix that confusion. Your patch will do it by not setting EndRecPtr yet; that fixes the bug, but leaves those variables in a slightly strange state; I'm not sure what EndRecPtr points to in that case (0 ?), but ReadRecPtr would be set I guess. Perhaps we should reset replayEndRecPtr and lastReplayedEndRecPtr to the REDO point here, instead of ReadRecPtr/EndRecPtr. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs