pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Andres Freund <andres@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Sergey Konoplev <gray.ru@gmail.com>
Cc: matioli.matheus@gmail.com
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Cc: Maxim Boguk <maxim.boguk@gmail.com>
Cc: Максим Панченко <Panchenko@gw.tander.ru>
Cc: Сизов Сергей Павлович <sizov_sp@gw.tander.ru>
Subject: Re: Hot standby 9.2.6 -> 9.2.6 PANIC: WAL contains references to invalid pages
Date: Mon, 13 Jan 2014 22:40:32 +0200
Message-ID: <52D44F40.1000803@vmware.com> (raw)
In-Reply-To: <20140113202600.GB14861@awork2.anarazel.de>
References: <CAL_0b1s4QCkFy_55kk_8XWcJPs7wsgVWf8vn4=jXe6V4R7Hxmg@mail.gmail.com>
	<20140106134815.GE28320@alap2.anarazel.de>
	<52CABF3E.2050004@vmware.com>
	<17450.1389644346@sss.pgh.pa.us>
	<20140113202600.GB14861@awork2.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 01/13/2014 10:26 PM, Andres Freund wrote:
> On 2014-01-13 15:19:06 -0500, Tom Lane wrote:
>> 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.

I think it's more natural to return the empty page to the caller, rather 
than InvalidBuffer.

> That's a sensible way to go, yes. But I wonder if we wouldn't end up
> with less complicated code if we added a variant of ReadBuffer that only
> returns a buffer from cache if already present in s_b.
> I started to prototype something like RBM_NORMAL_ZERO_OK shortly after
> Heikki's message and it seems to quickly turn a bit ugly because the
> surrounding code isn't really ready to deal with not returning a
> buffer. And for the purpose of that redo routine, that'd actually be
> better.

If it's trivial to add such a mode to buffer cache, then sure, let's do 
that by all means. But I seriously doubt it's really simple enough to be 
back-patchable.

With RBM_NORMAL_ZERO_OK, AFAICS we're talking about a tiny patch to 
XLogReadBufferExtended. bufmgr.c doesn't need to do anything about the 
new mode, as it's XLogReadBuffer that does the the check for zero pages. 
Per attached patch (for demonstration purposes only, you also need to 
add the new mode to the header file and adjust comments).

- Heikki

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

rbm_normal_zero_ok-1.patch (text/x-diff, 973B) download diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index 59f4233..958bcaa 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -296,6 +296,19 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum, BlockNumber lastblock; Buffer buffer; SMgrRelation smgr; + bool zero_page_allowed; + + if (mode == RBM_NORMAL_ZERO_OK) + { + /* + * Treat RBM_NORMAL_ZERO_OK just like RBM_NORMAL, except for the + * PageIsNew() check at the end. + */ + mode = RBM_NORMAL; + zero_page_allowed = true; + } + else + zero_page_allowed = false; Assert(blkno != P_NEW); @@ -343,7 +356,7 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum, Assert(BufferGetBlockNumber(buffer) == blkno); } - if (mode == RBM_NORMAL) + if (mode == RBM_NORMAL && !zero_page_allowed) { /* check that page has been initialized */ Page page = (Page) BufferGetPage(buffer);

view thread (36+ messages)  latest in thread

Message-ID: <52D44F40.1000803@vmware.com>
Permalink:  ../52D44F40.1000803@vmware.com/
Also on:    postgresql.org/message-id/52D44F40.1000803@vmware.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: hlinnakangas@vmware.com, andres@2ndquadrant.com, tgl@sss.pgh.pa.us, gray.ru@gmail.com, matioli.matheus@gmail.com, maxim.boguk@gmail.com, Panchenko@gw.tander.ru, sizov_sp@gw.tander.ru
  Subject: Re: Hot standby 9.2.6 -> 9.2.6 PANIC: WAL contains references to invalid pages
  In-Reply-To: <52D44F40.1000803@vmware.com>
  References: <CAL_0b1s4QCkFy_55kk_8XWcJPs7wsgVWf8vn4=jXe6V4R7Hxmg@mail.gmail.com> <20140106134815.GE28320@alap2.anarazel.de> <52CABF3E.2050004@vmware.com> <17450.1389644346@sss.pgh.pa.us> <20140113202600.GB14861@awork2.anarazel.de> <52D44F40.1000803@vmware.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox