mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
When Patroni does calculation whether it should run pg_rewind or not, it relies on pg_controldata output or gets necessary information from replication connection. On some cases (when for example postgres running as a master was killed), we can't use pg_controldata output immediately, but trying to start postgres. Such start could fail with the following errror: ``` LOG,00000,"ending log output to stderr",,"Future log output will go to log destination ""csvlog"".",,,,,,,"" LOG,00000,"database system was interrupted; last known up at 2017-09-16 22:35:22 UTC",,,,,,,,,"" LOG,00000,"restored log file ""00000006.history"" from archive",,,,,,,,,"" LOG,00000,"entering standby mode",,,,,,,,,"" 2017-09-18 08:00:39.433 UTC,,,57,,59bf7d26.39,4,,2017-09-18 08:00:38 UTC,,0,LOG,00000,"restored log file ""00000006.history"" from archive",,,,,,,,,"" FATAL,XX000,"requested timeline 6 is not a child of this server's history","Latest checkpoint is at 29/1A000178 on timeline 5, but in the history of the requested timeline, the server forked off from that timeline at 29/1A000140.",,,,,,,,"" LOG,00000,"startup process (PID 57) exited with exit code 1",,,,,,,,,"" LOG,00000,"aborting startup due to startup process failure",,,,,,,,,"" LOG,00000,"database system is shut down",,,,,,,,,"" ``` In this case controldata will still have `Database cluster state: in production` All further attempts to start postgres will fail. Such situation could be fixed only if we start not in recovery. For safety we will do it in a single user mode. The second problems is: if postgres was running as master, but later we started it and stopped, than pg_controldata will report: ``` Database cluster state: shut down in recovery Minimum recovery ending location: 0/0 Min recovery ending loc's timeline: 0 ``` And this info can't be used for calculations. In this case we should use `Latest checkpoint location` and `Latest checkpoint's TimeLineID`