Get the App
SLTechnology News&Howtos  ›  Database  › 

Determination of the timeline to which the recovery is initiated by PostgreSQL

Shulou Source: shulou.com Published: 2022-06-01 11:14:39 10月03日 Update

1. When starting the recovery, determine the timeline recoveryTargetTLI to which the recovery is going.

1) if the archive recovery point is larger than the timeline recorded in checkpoint, select the archive recovery point as the target timeline

2) otherwise, the timeline in the checkpoint record is used as the target timeline

StartupXLOG- > if (ControlFile- > minRecoveryPointTLI > ControlFile- > checkPointCopy.ThisTimeLineID) recoveryTargetTLI = ControlFile- > minRecoveryPointTLI; else recoveryTargetTLI = ControlFile- > checkPointCopy.ThisTimeLineID;.

2. Then read from the recovery.conf file

1) if the recovery_target_ time value is set and set to latest, then the largest timeline of the history list is the target timeline

2) otherwise, it is the timeline value set in the recovery.conf file

3) if the recovery_target_ time 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; else rtli = (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 (recoveryTargetTLI); recoveryTargetIsLatest = true }}

Tags: Time goal File Max Center Select Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Linux Docker macOS Apple