write_checkpoint_record_to_the_right_timeline.patch

text/x-patch

Filename: write_checkpoint_record_to_the_right_timeline.patch
Type: text/x-patch
Part: 0
Message: Re: PITR promote bug: Checkpointer writes to older timeline

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/access/transam/xlog.c 7 0
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 377afb8732..06d3ce676e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -9088,6 +9088,13 @@ CreateCheckPoint(int flags)
 	if (!shutdown && XLogStandbyInfoActive())
 		LogStandbySnapshot();
 
+	/*
+	 * ThisTimeLineID may have moved so far so we need to restore it so that
+	 * the checkpoint record goes to the right timeline.  (Currently
+	 * CheckPointTwoPhase() is known to have a chance to change it.)
+	 */
+	ThisTimeLineID = checkPoint.ThisTimeLineID;
+
 	START_CRIT_SECTION();
 
 	/*