Skip to content

Commit 5c89064

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/20170620171844.GC24975@momjian.us Backpatch-through: 9.2
1 parent f1e1f99 commit 5c89064

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

contrib/pg_upgrade/check.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,19 @@ report_clusters_compatible(void)
196196

197197

198198
void
199-
issue_warnings(char *sequence_script_file_name)
199+
issue_warnings_and_set_wal_level(char *sequence_script_file_name)
200200
{
201+
/*
202+
* We unconditionally start/stop the new server because pg_resetwal -o
203+
* set wal_level to 'minimum'. If the user is upgrading standby
204+
* servers using the rsync instructions, they will need pg_upgrade
205+
* to write its final WAL record with the proper wal_level.
206+
*/
207+
start_postmaster(&new_cluster, true);
208+
201209
/* old = PG 8.3 warnings? */
202210
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 803)
203211
{
204-
start_postmaster(&new_cluster, true);
205-
206212
/* restore proper sequence values using file created from old server */
207213
if (sequence_script_file_name)
208214
{
@@ -218,16 +224,13 @@ issue_warnings(char *sequence_script_file_name)
218224
old_8_3_rebuild_tsvector_tables(&new_cluster, false);
219225
old_8_3_invalidate_hash_gin_indexes(&new_cluster, false);
220226
old_8_3_invalidate_bpchar_pattern_ops_indexes(&new_cluster, false);
221-
stop_postmaster(false);
222227
}
223228

224229
/* Create dummy large object permissions for old < PG 9.0? */
225230
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
226-
{
227-
start_postmaster(&new_cluster, true);
228231
new_9_0_populate_pg_largeobject_metadata(&new_cluster, false);
229-
stop_postmaster(false);
230-
}
232+
233+
stop_postmaster(false);
231234
}
232235

233236

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ main(int argc, char **argv)
168168
create_script_for_cluster_analyze(&analyze_script_file_name);
169169
create_script_for_old_cluster_deletion(&deletion_script_file_name);
170170

171-
issue_warnings(sequence_script_file_name);
171+
issue_warnings_and_set_wal_level(sequence_script_file_name);
172172

173173
pg_log(PG_REPORT, "\nUpgrade Complete\n");
174174
pg_log(PG_REPORT, "----------------\n");

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void check_and_dump_old_cluster(bool live_check,
315315
char **sequence_script_file_name);
316316
void check_new_cluster(void);
317317
void report_clusters_compatible(void);
318-
void issue_warnings(char *sequence_script_file_name);
318+
void issue_warnings_and_set_wal_level(char *sequence_script_file_name);
319319
void output_completion_banner(char *analyze_script_file_name,
320320
char *deletion_script_file_name);
321321
void check_cluster_versions(void);

0 commit comments

Comments
 (0)