From: Nikolay Samokhvalov Date: Mon, 10 Jul 2023 20:07:18 +0000 Subject: [PATCH] Refine instructions for major upgrades on standby servers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recipe involving pg_upgrade -k and rsync --size-only can be dangerous – clarify what to do to avoid standby corruption. Discussion: https://www.postgresql.org/message-id/flat/CAM527d8heqkjG5VrvjU3Xjsqxg41ufUyabD9QZccdAxnpbRH-Q%40mail.gmail.com --- doc/src/sgml/ref/pgupgrade.sgml | 39 +++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml index 7816b4c6859..41242bb4200 100644 --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -361,10 +361,10 @@ make prefix=/usr/local/pgsql.new install - Stop both servers + Stop both primary servers - Make sure both database servers are stopped using, on Unix, e.g.: + Make sure both primary servers are stopped using, on Unix, e.g.: pg_ctl -D /opt/PostgreSQL/9.6 stop @@ -380,22 +380,28 @@ NET STOP postgresql-&majorversion; - Streaming replication and log-shipping standby servers can + Streaming replication and log-shipping standby servers must remain running until a later step. - + Prepare for standby server upgrades - If you are upgrading standby servers using methods outlined in section , verify that the old standby - servers are caught up by running pg_controldata - against the old primary and standby clusters. Verify that the - Latest checkpoint location values match in all clusters. - (There will be a mismatch if old standby servers were shut down - before the old primary or if the old standby servers are still running.) + If you are upgrading standby servers using methods outlined in + , ensure that they were running when + you shut down the primaries in the previous step, so all the latest changes + and the shutdown checkpoint record were received. You can verify this by running + pg_controldata against the old primary and standby + clusters. The Latest checkpoint location values must match in all + nodes. A mismatch might occur if old standby servers were shut down before + the old primary. To fix a mismatch, start all old servers and return to the + previous step; proceeding with mismatched + Latest checkpoint location may lead to standby corruption. + + + Also, make sure wal_level is not set to minimal in the postgresql.conf file on the new primary cluster. @@ -497,7 +503,6 @@ pg_upgrade.exe linkend="warm-standby"/>) standby servers, you can follow these steps to quickly upgrade them. You will not be running pg_upgrade on the standby servers, but rather rsync on the primary. - Do not start any servers yet. @@ -508,6 +513,16 @@ pg_upgrade.exe is running. + + Before running rsync, to avoid standby corruption, it is absolutely + critical to ensure that both old and new primary servers are shut down + and standby servers have received the last changes as discussed in + . + Standby servers can be running at this point or be fully stopped. If they + are still running. You can stop, upgrade, and start them one by one; this + can be useful to keep the cluster open for read-only transactions. + + --