From 74fc54085d20955cef4d5b7ce4b49d10351b1fbd Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Date: Thu, 21 Jul 2016 15:45:04 +0900
Subject: [PATCH 1/2] Add the reason why we use replayEndRecPtr as recovery-end
 point.

---
 src/backend/access/transam/xlog.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index aecede1..13ef75f 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -10409,10 +10409,14 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
 	 * required files are available, a user should wait for them to be
 	 * archived, or include them into the backup.
 	 *
-	 * We return the current minimum recovery point as the backup end
-	 * location. Note that it can be greater than the exact backup end
-	 * location if the minimum recovery point is updated after the backup of
-	 * pg_control. This is harmless for current uses.
+	 * minRecoveryPoint can go behind the last checkpoint's redo location when
+	 * the checkpoint writes out no buffer. This does no harm to performing a
+	 * recovery but such inversion seems inconsistent from the view of the
+	 * callers and prevents them from knowing WAL segments needed by sane
+	 * calcuation. For the reason we return the last replayed point as the
+	 * backup end location. Note that it can be greater than the exact backup
+	 * end location or even the minimum recovery point of pg_control at the
+	 * time. This is harmless for current uses.
 	 *
 	 * XXX currently a backup history file is for informational and debug
 	 * purposes only. It's not essential for an online backup. Furthermore,
-- 
1.8.3.1

