@@ -216,41 +216,46 @@ main(int argc, char **argv)
216216 * do.
217217 */
218218 if (ControlFile_target .checkPointCopy .ThisTimeLineID == ControlFile_source .checkPointCopy .ThisTimeLineID )
219- pg_fatal ("source and target cluster are on the same timeline\n" );
220-
221- findCommonAncestorTimeline (& divergerec , & lastcommontliIndex );
222- printf (_ ("servers diverged at WAL position %X/%X on timeline %u\n" ),
223- (uint32 ) (divergerec >> 32 ), (uint32 ) divergerec ,
224- targetHistory [lastcommontliIndex ].tli );
225-
226- /*
227- * Check for the possibility that the target is in fact a direct ancestor
228- * of the source. In that case, there is no divergent history in the
229- * target that needs rewinding.
230- */
231- if (ControlFile_target .checkPoint >= divergerec )
232219 {
233- rewind_needed = true;
220+ printf (_ ("source and target cluster are on the same timeline\n" ));
221+ rewind_needed = false;
234222 }
235223 else
236224 {
237- XLogRecPtr chkptendrec ;
238-
239- /* Read the checkpoint record on the target to see where it ends. */
240- chkptendrec = readOneRecord (datadir_target ,
241- ControlFile_target .checkPoint ,
242- targetNentries - 1 );
225+ findCommonAncestorTimeline (& divergerec , & lastcommontliIndex );
226+ printf (_ ("servers diverged at WAL position %X/%X on timeline %u\n" ),
227+ (uint32 ) (divergerec >> 32 ), (uint32 ) divergerec ,
228+ targetHistory [lastcommontliIndex ].tli );
243229
244230 /*
245- * If the histories diverged exactly at the end of the shutdown
246- * checkpoint record on the target, there are no WAL records in the
247- * target that don't belong in the source's history, and no rewind is
248- * needed.
231+ * Check for the possibility that the target is in fact a direct ancestor
232+ * of the source. In that case, there is no divergent history in the
233+ * target that needs rewinding.
249234 */
250- if (chkptendrec == divergerec )
251- rewind_needed = false;
252- else
235+ if (ControlFile_target .checkPoint >= divergerec )
236+ {
253237 rewind_needed = true;
238+ }
239+ else
240+ {
241+ XLogRecPtr chkptendrec ;
242+
243+ /* Read the checkpoint record on the target to see where it ends. */
244+ chkptendrec = readOneRecord (datadir_target ,
245+ ControlFile_target .checkPoint ,
246+ targetNentries - 1 );
247+
248+ /*
249+ * If the histories diverged exactly at the end of the shutdown
250+ * checkpoint record on the target, there are no WAL records in the
251+ * target that don't belong in the source's history, and no rewind is
252+ * needed.
253+ */
254+ if (chkptendrec == divergerec )
255+ rewind_needed = false;
256+ else
257+ rewind_needed = true;
258+ }
254259 }
255260
256261 if (!rewind_needed )
0 commit comments