Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W34SR-00012e-Sz for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Jan 2014 13:55:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W34SR-0006qo-Bs for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Jan 2014 13:55:07 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W34SQ-0006qE-IK for pgsql-bugs@postgresql.org; Tue, 14 Jan 2014 13:55:06 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W34SJ-0006rG-98 for pgsql-bugs@postgresql.org; Tue, 14 Jan 2014 13:55:05 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 6A6E228484; Tue, 14 Jan 2014 05:54:58 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 608E5B0169; Tue, 14 Jan 2014 05:54:58 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 2603E120030; Tue, 14 Jan 2014 05:56:20 -0800 (PST) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Tue, 14 Jan 2014 05:56:18 -0800 (PST) Message-ID: <52D54198.7090802@vmware.com> Date: Tue, 14 Jan 2014 15:54:32 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Tom Lane CC: Andres Freund , Sergey Konoplev , matioli.matheus@gmail.com, pgsql-bugs , Maxim Boguk , =?UTF-8?B?0JzQsNC60YHQuNC8INCf0LDQvdGH0LXQvdC60L4=?= , =?UTF-8?B?0KHQuNC30L7QsiDQodC10YDQs9C10Lkg0J/QsA==?= =?UTF-8?B?0LLQu9C+0LLQuNGH?= Subject: Re: Hot standby 9.2.6 -> 9.2.6 PANIC: WAL contains references to invalid pages References: <20140106134815.GE28320@alap2.anarazel.de> <52CABF3E.2050004@vmware.com> <17450.1389644346@sss.pgh.pa.us> <20140113202600.GB14861@awork2.anarazel.de> <52D44F40.1000803@vmware.com> <20140113210245.GD14861@awork2.anarazel.de> <52D45AD7.9080406@vmware.com> <20140113220440.GE5838@awork2.anarazel.de> <25048.1389662159@sss.pgh.pa.us> <20140114011851.GA20335@awork2.anarazel.de> <26165.1389664788@sss.pgh.pa.us> In-Reply-To: <26165.1389664788@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.0 (-------) 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 01/14/2014 03:59 AM, Tom Lane wrote: > BTW, while I'm looking at this ... the writing side of the code seems a > few bricks shy of a load too: > > /* > * InHotStandby we need to scan right up to the end of the index for > * correct locking, so we may need to write a WAL record for the final > * block in the index if it was not vacuumed. It's possible that VACUUMing > * has actually removed zeroed pages at the end of the index so we need to > * take care to issue the record for last actual block and not for the > * last block that was scanned. Ignore empty indexes. > */ > if (XLogStandbyInfoActive() && > num_pages > 1 && vstate.lastBlockVacuumed < (num_pages - 1)) > { > Buffer buf; > > /* > * We can't use _bt_getbuf() here because it always applies > * _bt_checkpage(), which will barf on an all-zero page. We want to > * recycle all-zero pages, not fail. Also, we want to use a > * nondefault buffer access strategy. > */ > buf = ReadBufferExtended(rel, MAIN_FORKNUM, num_pages - 1, RBM_NORMAL, > info->strategy); > LockBufferForCleanup(buf); > _bt_delitems_vacuum(rel, buf, NULL, 0, vstate.lastBlockVacuumed); > _bt_relbuf(rel, buf); > } > > If the last physical page of the index is all-zero, the preceding loop > won't have any problem with that (nor should it); but this code sure will > have a problem, because _bt_delitems_vacuum isn't prepared to cope with an > all-zero page AFAICS. Yep, that's broken. > Nor am I following the logic of the initial comment. If we know that > pages above N are all-zero, why are we worried about taking locks on them? > There shouldn't be any scans reaching such pages, and any that did would > error out anyhow in _bt_getbuf(). Also, btree relations are never truncated, so the comment is wrong when it claims that VACUUM might've removed zero pages at the end of the index. > ISTM the right thing here is for the btvacuumpage loop to remember the > last ordinary, valid index page it saw, and point to that one in this > added WAL entry. Agreed. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs