Get the App
SLTechnology News&Howtos  ›  Database  › 

PostgreSQL problem analysis 1: the timeline is inconsistent

Shulou Source: shulou.com Published: 2022-06-01 12:39:17 09月15日 Update

First, question: requested timeline% u does not contain minimum recovery point% X on timeline% u

The location of the log in the code is as follows:

StartupXLOG: if (! XLogRecPtrIsInvalid (ControlFile- > minRecoveryPoint) & & tliOfPointInHistory (ControlFile- > minRecoveryPoint-1, expectedTLEs)! = ControlFile- > minRecoveryPointTLI) ereport (FATAL, (errmsg ("requested timeline% u does not contain minimum recovery point% X minRecoveryPointTLI% X on timeline% u", recoveryTargetTLI, (uint32) (ControlFile- > minRecoveryPoint > > 32) (uint32) ControlFile- > minRecoveryPoint, ControlFile- > minRecoveryPointTLI)

2. Analysis

What is the value of recoveryTargetTLI?

1. During the start-up and recovery process, the change value is as follows:

StartupXLOG:... If (ControlFile- > minRecoveryPointTLI > ControlFile- > checkPointCopy.ThisTimeLineID) recoveryTargetTLI = ControlFile- > minRecoveryPointTLI; else recoveryTargetTLI = ControlFile- > checkPointCopy.ThisTimeLineID; readRecoveryCommandFile ();-- for (item = head; item; item = item- > next) {|... | 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); |} |. |} | | if (rtliGiven) {| if (rtli) {| recoveryTargetTLI = rtli | | | recoveryTargetIsLatest = false; |} else {| recoveryTargetTLI = findNewestTimeLine (recoveryTargetTLI); | recoveryTargetIsLatest = true; |} |--} |

First, the timeline ControlFile- > minRecoveryPointTLI of the minimum recovery point recorded by the pg_control file is compared with the timeline ControlFile- > checkPointCopy.ThisTimeLineID of the checkpoint recorded by the pg_control file, and the recoveryTargetTLI takes a larger value between the two.

ReadRecoveryCommandFile then reads the recovery.cnf file, and if it is a host, there is no recovery.cnf file. The value of recovery_target_timeline in the recovery.cnf file specifies the timeline to which it is restored. If it is latest, the timeline rtli is 0 otherwise it is the specified value; if rtli is the specified value, then recoveryTargetTLI is the specified value, otherwise, starting from the recoveryTargetTLI value obtained in the first step, see if there is a history file for it, and find the maximum timeline for the history file for which recoveryTargetTLI is the timeline.

Tags: File time problem analysis maximum minimum larger host between code location process change consistency Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker NVidia Shulou Tech Info Huawei Shulou Information