Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2nzJ-0005pQ-0R for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jan 2014 20:19:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W2nzI-00045W-G1 for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jan 2014 20:19:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2nzG-00043y-U2 for pgsql-bugs@postgresql.org; Mon, 13 Jan 2014 20:19:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W2nzE-0001pI-Jt for pgsql-bugs@postgresql.org; Mon, 13 Jan 2014 20:19:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s0DKJ6fa017451; Mon, 13 Jan 2014 15:19:06 -0500 From: Tom Lane To: Heikki Linnakangas cc: Andres Freund , Sergey Konoplev , matioli.matheus@gmail.com, pgsql-bugs , Maxim Boguk , =?UTF-8?B?0JzQsNC60YHQuNC8INCf0LDQvQ==?= =?UTF-8?B?0YfQtdC90LrQvg==?= , =?UTF-8?B?0KHQuNC3?= =?UTF-8?B?0L7QsiDQodC10YDQs9C10Lkg0J/QsNCy0LvQvtCy0LjRhw==?= Subject: Re: Hot standby 9.2.6 -> 9.2.6 PANIC: WAL contains references to invalid pages In-reply-to: <52CABF3E.2050004@vmware.com> References: <20140106134815.GE28320@alap2.anarazel.de> <52CABF3E.2050004@vmware.com> Comments: In-reply-to Heikki Linnakangas message dated "Mon, 06 Jan 2014 16:35:42 +0200" Date: Mon, 13 Jan 2014 15:19:06 -0500 Message-ID: <17450.1389644346@sss.pgh.pa.us> X-Pg-Spam-Score: -2.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 Heikki Linnakangas writes: > On 01/06/2014 03:48 PM, Andres Freund wrote: >> There just was another case of this reported on IRC by MatheusOl and for >> some reason in his case I noticed the pertinent details and it quickly >> clicked: >> * page 14833 is the one with the error >> * we're actually vacuuming page 38538 >> * lastBlockVacuumed is 0 >> >> In btree_xlog_vacuum() we scan all the pages between lastBlockVacuumed >> and the page vacuumed and acquire a cleanup lock on it. But there isn't >> any guarantee that the intermediate pages are valid, filled pages, >> afaics. > Hmm. So the problem arises if there's an uninitialized page in the > middle of the b-tree relation for some reason. It's unusual for an > uninitialized page to be left in the middle of the relation, but it's > certainly possible, if e.g you crash just after extending the relation. Right. This diagnosis is incomplete in itself, because if the slave has a zeroed page there, shouldn't the master have one too? If the master does have a zeroed page there, how come vacuum didn't fail on the master? The answer is that btvacuumpage will skip over all-zero pages without doing anything more than noting them as free in FSM. When btree_xlog_vacuum rescans the relation, it will also skip over all-zero pages without doing anything --- but XLogReadBufferExtended logs such a page as invalid, and then bitches later when it doesn't see the page dropped or truncated away. >> ISTM we can just use RBM_ZERO_ON_ERROR instead of RBM_NORMAL. > That'd be horrendously dangerous. It would silently zap any page with > any error on it. But we could add a new ReadBufferMode that returns > InvalidBuffer on error, without zeroing the page. The important point is not just that it not damage the page, but that it not log it as invalid. I concur that the right fix requires a new operating mode for XLogReadBufferExtended, perhaps RBM_NORMAL_ZERO_OK. I think the spec for this should be that if the page doesn't exist or contains zeroes, we return InvalidBuffer without logging the page number as invalid. The doesn't-exist case is justified by the expectation that there will be a later RBM_NORMAL call for a larger page number, which will result in a suitable complaint if the page range isn't there. Will go fix this if there's not any objection to that plan. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs