1. When you start recovery, determine the time line that you restored to Recoverytargettli
1) Archive recovery point is larger than the time line recorded in Checkpoint, then select Archive recovery point as target timeline
2) Otherwise, the time line in the checkpoint record as the target timeline
Startupxlog->if (Controlfile->minrecoverypointtli >controlfile->checkpointcopy.thistimelineid) Recoverytargettli = Controlfile->minrecoverypointtli;elserecoverytargettli = controlfile-> Checkpointcopy.thistimelineid, .....
2. Then read from the recovery.conf file
1) If the Recovery_target_timeline value is set and is set to latest, then the maximum timeline for the history list is the target time line
2) Otherwise, the time line value set in the Recovery.conf file
3) If the Recovery_target_timeline value is not set, the target timeline is the value in the first step
Startupxlog->readrecoverycommandfile ()->for (item = head; item; item = Item->next) {if (strcmp (Item->name, " Restore_command ") = = 0) {...} else If ... else if (strcmp (Item->name, "recovery_target_timeline") = = 0) {Rtligiven = True;if (strcmp (Item->value, " Latest ") = = 0) Rtli = 0;elsertli = (Timelineid) strtoul (item->value, NULL, 0);} else If ...} if (Rtligiven) {if (Rtli) {Recoverytargettli = Rtli;recoverytargetislatest = false;} else{/* We start the "latest" search from Pg_control ' s timeline */recoverytargettli = Findnewesttimeline (recoverytargettl I); recoverytargetislatest = True;}}
When PostgreSQL initiates recovery, the recovery to the timeline is determined