Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
pg_upgrade: start/stop new server after pg_resetwal
authorBruce Momjian <bruce@momjian.us>
Tue, 20 Jun 2017 17:20:02 +0000 (13:20 -0400)
committerBruce Momjian <bruce@momjian.us>
Tue, 20 Jun 2017 17:20:02 +0000 (13:20 -0400)
When commit 0f33a719fdbb5d8c43839ea0d2c90cd03e2af2d2 removed the
instructions to start/stop the new cluster before running rsync, it was
now possible for pg_resetwal/pg_resetxlog to leave the final WAL record
at wal_level=minimum, preventing upgraded standby servers from
reconnecting.

This patch fixes that by having pg_upgrade unconditionally start/stop
the new cluster after pg_resetwal/pg_resetxlog has run.

Backpatch through 9.2 since, though the instructions were added in PG
9.5, they worked all the way back to 9.2.

Discussion: https://postgr.es/m/20170620171844.GC24975@momjian.us

Backpatch-through: 9.2

contrib/pg_upgrade/check.c
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/pg_upgrade.h

index 7c4f2b98bbf9ac635592470323d238e6cc96148d..140a2b6ec551b4efde34436f9ee4b6d9224a4f6f 100644 (file)
@@ -202,13 +202,19 @@ report_clusters_compatible(void)
 
 
 void
-issue_warnings(char *sequence_script_file_name)
+issue_warnings_and_set_wal_level(char *sequence_script_file_name)
 {
+   /*
+    * We unconditionally start/stop the new server because pg_resetwal -o
+    * set wal_level to 'minimum'.  If the user is upgrading standby
+    * servers using the rsync instructions, they will need pg_upgrade
+    * to write its final WAL record with the proper wal_level.
+    */
+   start_postmaster(&new_cluster);
+
    /* old = PG 8.3 warnings? */
    if (GET_MAJOR_VERSION(old_cluster.major_version) <= 803)
    {
-       start_postmaster(&new_cluster);
-
        /* restore proper sequence values using file created from old server */
        if (sequence_script_file_name)
        {
@@ -224,16 +230,13 @@ issue_warnings(char *sequence_script_file_name)
        old_8_3_rebuild_tsvector_tables(&new_cluster, false);
        old_8_3_invalidate_hash_gin_indexes(&new_cluster, false);
        old_8_3_invalidate_bpchar_pattern_ops_indexes(&new_cluster, false);
-       stop_postmaster(false);
    }
 
    /* Create dummy large object permissions for old < PG 9.0? */
    if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
-   {
-       start_postmaster(&new_cluster);
        new_9_0_populate_pg_largeobject_metadata(&new_cluster, false);
-       stop_postmaster(false);
-   }
+
+   stop_postmaster(false);
 }
 
 
index 752c821b11c9c26e637a6360e851a782fbdcc494..eff1e9826febdc1743b47eea447649125baf3809 100644 (file)
@@ -163,7 +163,7 @@ main(int argc, char **argv)
    create_script_for_cluster_analyze(&analyze_script_file_name);
    create_script_for_old_cluster_deletion(&deletion_script_file_name);
 
-   issue_warnings(sequence_script_file_name);
+   issue_warnings_and_set_wal_level(sequence_script_file_name);
 
    pg_log(PG_REPORT, "\nUpgrade Complete\n");
    pg_log(PG_REPORT, "----------------\n");
index 6a968ea719e1694b5e11ef2582e3127053fee340..6d0f7252e22c38d8eeb89a8a3d388116019ab510 100644 (file)
@@ -301,7 +301,7 @@ void check_old_cluster(bool live_check,
                  char **sequence_script_file_name);
 void       check_new_cluster(void);
 void       report_clusters_compatible(void);
-void       issue_warnings(char *sequence_script_file_name);
+void       issue_warnings_and_set_wal_level(char *sequence_script_file_name);
 void output_completion_banner(char *analyze_script_file_name,
                         char *deletion_script_file_name);
 void       check_cluster_versions(void);