pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@2ndquadrant.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: Sergey Konoplev <gray.ru@gmail.com>
Cc: pgsql-bugs@postgresql.org
Cc: Maxim Boguk <maxim.boguk@gmail.com>
Cc: Максим Панченко <Panchenko@gw.tander.ru>
Cc: Толстенко Илья <tolstenko_iv@gw.tander.ru>
Subject: Re: Completely broken replica after PANIC: WAL contains references to invalid pages
Date: Tue, 2 Apr 2013 12:10:12 +0200
Message-ID: <20130402101012.GB2415@alap2.anarazel.de> (raw)
In-Reply-To: <CA+U5nMKMSkcxr5HjrTzXtcMybK-0DAFQhOJ8G2KsvZMGtgULGA@mail.gmail.com>
References: <CAL_0b1t=WuM6roO8dki=w8DhH8P8whhohbPjReymmQUrOcNT2A@mail.gmail.com>
	<675b7cee-b7f0-4e32-8e34-1efaf3ca5fe9@email.android.com>
	<CAL_0b1vLSGx=ENLkSK1cyDtGcYVAb_im051w-bza3H-7dPgTBA@mail.gmail.com>
	<20130329213834.GA26976@awork2.anarazel.de>
	<CAL_0b1sJHOwmSDRkP8a8QFKVDTrvEkxN_LfD-GaBSPS4LC2v_w@mail.gmail.com>
	<20130330172144.GI28736@alap2.anarazel.de>
	<CA+U5nMKMSkcxr5HjrTzXtcMybK-0DAFQhOJ8G2KsvZMGtgULGA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 2013-04-01 08:49:16 +0100, Simon Riggs wrote:
> On 30 March 2013 17:21, Andres Freund <andres@2ndquadrant.com> wrote:
> 
> > So if the xid is later than latestObservedXid we extend subtrans one by
> > one. So far so good. But we initialize it in
> > ProcArrayApplyRecoveryInfo() when consistency is initially reached:
> >                              latestObservedXid = running->nextXid;
> >                              TransactionIdRetreat(latestObservedXid);
> > Before that subtrans has initially been started up with:
> >                         if (wasShutdown)
> >                                 oldestActiveXID = PrescanPreparedTransactions(&xids, &nxids);
> >                         else
> >                                 oldestActiveXID = checkPoint.oldestActiveXid;
> > ...
> >                         StartupSUBTRANS(oldestActiveXID);
> >
> > That means its only initialized up to checkPoint.oldestActiveXid. As it
> > can take some time till we reach consistency it seems rather plausible
> > that there now will be a gap in initilized pages. From
> > checkPoint.oldestActiveXid to running->nextXid if there are pages
> > inbetween.
> 
> That was an old bug.
> 
> StartupSUBTRANS() now explicitly fills that gap. Are you saying it
> does that incorrectly? How?

Well, no. I think StartupSUBTRANS does this correctly, but there's a gap
between the call to Startup* and the first call to ExtendSUBTRANS. The
latter is only called *after* we reached STANDBY_INITIALIZED via
ProcArrayApplyRecoveryInfo(). The problem is that we StartupSUBTRANS to
checkPoint.oldestActiveXid while we start to ExtendSUBTRANS from
running->nextXid - 1. There very well can be a gap inbetween.
The window isn't terribly big but if you use subtransactions as heavily
as Sergey seems to be it doesn't seem unlikely to hit it.

Let me come up with a testcase and patch.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
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 (29+ messages)  latest in thread

Message-ID: <20130402101012.GB2415@alap2.anarazel.de>
Permalink:  ../20130402101012.GB2415@alap2.anarazel.de/
Also on:    postgresql.org/message-id/20130402101012.GB2415@alap2.anarazel.de

 · 

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: andres@2ndquadrant.com, simon@2ndQuadrant.com, gray.ru@gmail.com, maxim.boguk@gmail.com, Panchenko@gw.tander.ru, tolstenko_iv@gw.tander.ru
  Subject: Re: Completely broken replica after PANIC: WAL contains references to invalid pages
  In-Reply-To: <20130402101012.GB2415@alap2.anarazel.de>
  References: <CAL_0b1t=WuM6roO8dki=w8DhH8P8whhohbPjReymmQUrOcNT2A@mail.gmail.com> <675b7cee-b7f0-4e32-8e34-1efaf3ca5fe9@email.android.com> <CAL_0b1vLSGx=ENLkSK1cyDtGcYVAb_im051w-bza3H-7dPgTBA@mail.gmail.com> <20130329213834.GA26976@awork2.anarazel.de> <CAL_0b1sJHOwmSDRkP8a8QFKVDTrvEkxN_LfD-GaBSPS4LC2v_w@mail.gmail.com> <20130330172144.GI28736@alap2.anarazel.de> <CA+U5nMKMSkcxr5HjrTzXtcMybK-0DAFQhOJ8G2KsvZMGtgULGA@mail.gmail.com> <20130402101012.GB2415@alap2.anarazel.de>

* 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