Skip to content

Commit 0efdbd3

Browse files
committed
pg_upgrade: start/stop new server after pg_resetwal
When commit 0f33a71 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/[email protected] Backpatch-through: 9.2
1 parent 1dce053 commit 0efdbd3

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/bin/pg_upgrade/check.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,21 @@ report_clusters_compatible(void)
164164

165165

166166
void
167-
issue_warnings(void)
167+
issue_warnings_and_set_wal_level(void)
168168
{
169+
/*
170+
* We unconditionally start/stop the new server because pg_resetwal -o
171+
* set wal_level to 'minimum'. If the user is upgrading standby
172+
* servers using the rsync instructions, they will need pg_upgrade
173+
* to write its final WAL record showing wal_level as 'replica'.
174+
*/
175+
start_postmaster(&new_cluster, true);
176+
169177
/* Create dummy large object permissions for old < PG 9.0? */
170178
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
171-
{
172-
start_postmaster(&new_cluster, true);
173179
new_9_0_populate_pg_largeobject_metadata(&new_cluster, false);
174-
stop_postmaster(false);
175-
}
180+
181+
stop_postmaster(false);
176182
}
177183

178184

src/bin/pg_upgrade/pg_upgrade.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ main(int argc, char **argv)
160160
create_script_for_cluster_analyze(&analyze_script_file_name);
161161
create_script_for_old_cluster_deletion(&deletion_script_file_name);
162162

163-
issue_warnings();
163+
issue_warnings_and_set_wal_level();
164164

165165
pg_log(PG_REPORT, "\nUpgrade Complete\n");
166166
pg_log(PG_REPORT, "----------------\n");

src/bin/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void output_check_banner(bool live_check);
334334
void check_and_dump_old_cluster(bool live_check);
335335
void check_new_cluster(void);
336336
void report_clusters_compatible(void);
337-
void issue_warnings(void);
337+
void issue_warnings_and_set_wal_level(void);
338338
void output_completion_banner(char *analyze_script_file_name,
339339
char *deletion_script_file_name);
340340
void check_cluster_versions(void);

0 commit comments

Comments
 (0)