From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Simon Riggs <simon@2ndQuadrant.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: PITR potentially broken in 9.2
Date: Wed, 5 Dec 2012 22:56:52 +0100
Message-ID: <20121205215651.GU27424@awork2.anarazel.de> (raw)
In-Reply-To: <12846.1354742138@sss.pgh.pa.us>
References: <6461.1354723883@sss.pgh.pa.us>
<20121205162421.GB20456@awork2.anarazel.de>
<7015.1354725616@sss.pgh.pa.us>
<CA+U5nM+AHnYOv5+xE0ogFM82gdPfmZ4osRutT-BT2DW3LrGPfA@mail.gmail.com>
<CA+U5nMKKY4NTJa+i5OJYs2Mh8i=B3249A3ji=L0-hr4c1G7qMw@mail.gmail.com>
<20121205173025.GD27424@awork2.anarazel.de>
<8223.1354728999@sss.pgh.pa.us>
<9918.1354733333@sss.pgh.pa.us>
<CA+U5nMLfV4OT31df7Uc2BXLM0-NUqk-qdLsYQ5jPTa4Ejwv+sw@mail.gmail.com>
<12846.1354742138@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 2012-12-05 16:15:38 -0500, Tom Lane wrote:
> Simon Riggs <simon@2ndQuadrant.com> writes:
> > On 5 December 2012 18:48, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> On further thought, it seems like recovery_pause_at_target is rather
> >> misdesigned anyway, and taking recovery target parameters from
> >> recovery.conf is an obsolete API that was designed in a world before hot
> >> standby. What I suggest people really want, if they're trying to
> >> interactively determine how far to roll forward, is this:
> >> ...
>
> > Can't remember why we didn't go for the full API last time. I'll have
> > another go, in HEAD.
>
> That's fine, but the immediate question is what are we doing to fix
> the back branches. I think everyone is clear that we should be testing
> LocalHotStandbyActive rather than precursor conditions to see if a pause
> is allowed, but are we going to do anything more than that?
I'd like to have inclusive/non-inclusive stops some resemblance of
sanity.
Raw patch including your earlier LocalHotStandbyActive one attached.
> The only other thing I really wanted to do is not have the in-loop pause
> occur after we've taken actions that are effectively part of the WAL
> apply step. I think ideally it should happen just before or after the
> recoveryStopsHere stanza. Last night I worried about adding an extra
> spinlock acquire to make that work, but today I wonder if we couldn't
> get away with just a naked
>
> if (xlogctl->recoveryPause)
> recoveryPausesHere();
> The argument for this is that although we might fetch a slightly stale
> value of the shared variable, it can't be very stale --- certainly no
> older than the spinlock acquisition near the bottom of the previous
> iteration of the loop. And this is a highly asynchronous feature
> anyhow, so fuzziness of plus or minus one WAL record in when the pause
> gets honored is not going to be detectable. Hence an extra spinlock
> acquisition is not worth the cost.
Seems safe enough to me. But I am not sure its necessary, if we move
the recoveryPausesHere() down after replaying the record, fetching
inside the spinlock for recoveryLastRecPtr seems to be natural enough.
Greetings,
Andres Freund
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:recovery-pause.patch (text/x-patch, 2.4K) downloaddiff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.cindex 187b609..e962f62 100644--- a/src/backend/access/transam/xlog.c+++ b/src/backend/access/transam/xlog.c@@ -5923,6 +5923,10 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
static void
recoveryPausesHere(void)
{
+ /* Don't pause unless users can connect! */+ if (!LocalHotStandbyActive)+ return;+
ereport(LOG,
(errmsg("recovery has paused"),
errhint("Execute pg_xlog_replay_resume() to continue.")));
@@ -6697,19 +6701,18 @@ StartupXLOG(void)
*/
if (recoveryStopsHere(record, &recoveryApply))
{
- /*- * Pause only if users can connect to send a resume- * message- */- if (recoveryPauseAtTarget && standbyState == STANDBY_SNAPSHOT_READY)- {+ if (recoveryPauseAtTarget)
SetRecoveryPause(true);
- recoveryPausesHere();- }+
reachedStopPoint = true; /* see below */
recoveryContinue = false;
++ /* break out if we have non-inclusive recovery target */
if (!recoveryApply)
+ {+ recoveryPausesHere();
break;
+ }
}
/* Setup error traceback support for ereport() */
@@ -6737,19 +6740,14 @@ StartupXLOG(void)
/*
* Update shared replayEndRecPtr before replaying this record,
* so that XLogFlush will update minRecoveryPoint correctly.
+ *+ * While we have the lock, also check for a pause request.
*/
SpinLockAcquire(&xlogctl->info_lck);
xlogctl->replayEndRecPtr = EndRecPtr;
- recoveryPause = xlogctl->recoveryPause;
SpinLockRelease(&xlogctl->info_lck);
/*
- * Pause only if users can connect to send a resume message- */- if (recoveryPause && standbyState == STANDBY_SNAPSHOT_READY)- recoveryPausesHere();-- /*
* If we are attempting to enter Hot Standby mode, process
* XIDs we see
*/
@@ -6790,10 +6788,19 @@ StartupXLOG(void)
*/
SpinLockAcquire(&xlogctl->info_lck);
xlogctl->recoveryLastRecPtr = EndRecPtr;
+ recoveryPause = xlogctl->recoveryPause;
SpinLockRelease(&xlogctl->info_lck);
LastRec = ReadRecPtr;
++ if (recoveryPause)+ recoveryPausesHere();++ /* if we have inclusive recovery target */+ if (!recoveryStopsHere)+ break;+
record = ReadRecord(NULL, LOG, false);
} while (record != NULL && recoveryContinue);
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@anarazel.de, tgl@sss.pgh.pa.us, simon@2ndQuadrant.com, jeff.janes@gmail.com, hlinnakangas@vmware.com, noah@leadboat.com
Subject: Re: PITR potentially broken in 9.2
In-Reply-To: <20121205215651.GU27424@awork2.anarazel.de>
References: <6461.1354723883@sss.pgh.pa.us> <20121205162421.GB20456@awork2.anarazel.de> <7015.1354725616@sss.pgh.pa.us> <CA+U5nM+AHnYOv5+xE0ogFM82gdPfmZ4osRutT-BT2DW3LrGPfA@mail.gmail.com> <CA+U5nMKKY4NTJa+i5OJYs2Mh8i=B3249A3ji=L0-hr4c1G7qMw@mail.gmail.com> <20121205173025.GD27424@awork2.anarazel.de> <8223.1354728999@sss.pgh.pa.us> <9918.1354733333@sss.pgh.pa.us> <CA+U5nMLfV4OT31df7Uc2BXLM0-NUqk-qdLsYQ5jPTa4Ejwv+sw@mail.gmail.com> <12846.1354742138@sss.pgh.pa.us> <20121205215651.GU27424@awork2.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