]> granicus.if.org Git - postgresql/commitdiff
Fix pause_at_recovery_target + recovery_target_inclusive combination.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Jan 2014 21:06:03 +0000 (23:06 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Jan 2014 21:30:55 +0000 (23:30 +0200)
If pause_at_recovery_target is set, recovery pauses *before* applying the
target record, even if recovery_target_inclusive is set. If you then
continue with pg_xlog_replay_resume(), it will apply the target record
before ending recovery. In other words, if you log in while it's paused
and verify that the database looks OK, ending recovery changes its state
again, possibly destroying data that you were tring to salvage with PITR.

Backpatch to 9.1, this has been broken since pause_at_recovery_target was
added.

src/backend/access/transam/xlog.c

index de17f722dfc1affa52e243f40648e283d0a8709d..679720a33ee0279f07675ec5d130f747c1500372 100644 (file)
@@ -6868,11 +6868,6 @@ StartupXLOG(void)
                                 */
                                if (recoveryStopsHere(record, &recoveryApply))
                                {
-                                       if (recoveryPauseAtTarget)
-                                       {
-                                               SetRecoveryPause(true);
-                                               recoveryPausesHere();
-                                       }
                                        reachedStopPoint = true;        /* see below */
                                        recoveryContinue = false;
 
@@ -6951,6 +6946,12 @@ StartupXLOG(void)
                         * end of main redo apply loop
                         */
 
+                       if (recoveryPauseAtTarget && reachedStopPoint)
+                       {
+                               SetRecoveryPause(true);
+                               recoveryPausesHere();
+                       }
+
                        ereport(LOG,
                                        (errmsg("redo done at %X/%X",
                                                        ReadRecPtr.xlogid, ReadRecPtr.xrecoff)));