pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@2ndquadrant.com>
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: Tue, 14 Jan 2014 15:54:32 +0200
Message-ID: <52D54198.7090802@vmware.com> (raw)
In-Reply-To: <26165.1389664788@sss.pgh.pa.us>
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>
	<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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (36+ messages)  latest in thread

Message-ID: <52D54198.7090802@vmware.com>
Permalink:  ../52D54198.7090802@vmware.com/
Also on:    postgresql.org/message-id/52D54198.7090802@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, tgl@sss.pgh.pa.us, andres@2ndquadrant.com, 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: <52D54198.7090802@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> <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> <52D54198.7090802@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