pgsql: Ensure recovery pause feature doesn't pause unless users can con

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Ensure recovery pause feature doesn't pause unless users can con
Date: 2012-12-05 23:28:19
Message-ID: E1TgOO3-0004b8-7q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Ensure recovery pause feature doesn't pause unless users can connect.

If we're not in hot standby mode, then there's no way for users to connect
to reset the recoveryPause flag, so we shouldn't pause. The code was aware
of this but the test to see if pausing was safe was seriously inadequate:
it wasn't paying attention to reachedConsistency, and besides what it was
testing was that we could legally enter hot standby, not that we have
done so. Get rid of that in favor of checking LocalHotStandbyActive,
which because of the coding in CheckRecoveryConsistency is tantamount to
checking that we have told the postmaster to enter hot standby.

Also, move the recoveryPausesHere() call that reacts to asynchronous
recoveryPause requests so that it's not in the middle of application of a
WAL record. I put it next to the recoveryStopsHere() call --- in future
those are going to need to interact significantly, so this seems like a
good waystation.

Also, don't bother trying to read another WAL record if we've already
decided not to continue recovery. This was no big deal when the code was
written originally, but now that reading a record might entail actions like
fetching an archive file, it seems a bit silly to do it like that.

Per report from Jeff Janes and subsequent discussion. The pause feature
needs quite a lot more work, but this gets rid of some indisputable bugs,
and seems safe enough to back-patch.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/161021dd4cc467277575533af7ce5274c0ea43d7

Modified Files
--------------
src/backend/access/transam/xlog.c | 50 +++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2012-12-06 02:11:39 pgsql: Update comment at top of index_create
Previous Message Heikki Linnakangas 2012-12-05 19:01:45 pgsql: Oops, meant to change the comment in writeTimeLineHistory.