Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7021d3b

Browse files
committed
Prevent startup of logical replication launcher during pg_upgrade
The logical replication launcher may start apply workers during an upgrade. This could be the cause of corruptions on a new cluster if these are able to apply changes before the physical files are copied over to the new cluster. The chance of being able to do so is small as pg_upgrade uses its own port and unix domain directory (the latter is customizable with --socketdir), but just preventing the launcher to start is safer at the end, because we are then sure that no changes will be applied. Like 29d0a77 for max_slot_wal_keep_size, this is only set when a cluster uses v17 or newer. Author: Vignesh C Discussion: https://postgr.es/m/CALDaNm2g9ZKf=y8X6z6MsLCuh8WwU-=Q6pLj35NFi2M5BZNS_A@mail.gmail.com
1 parent 40d5e59 commit 7021d3b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bin/pg_upgrade/server.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,17 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
248248
* invalidation of slots during the upgrade. We set this option when
249249
* cluster is PG17 or later because logical replication slots can only be
250250
* migrated since then. Besides, max_slot_wal_keep_size is added in PG13.
251+
*
252+
* Use max_logical_replication_workers as 0 to prevent a startup of the
253+
* logical replication launcher while upgrading because it may start apply
254+
* workers that could start receiving changes from the publisher before
255+
* the physical files are put in place, causing corruption on the new
256+
* cluster upgrading to. Like the previous parameter, this is set only
257+
* when a cluster is PG17 or later as logical slots can only be migrated
258+
* since this version.
251259
*/
252260
if (GET_MAJOR_VERSION(cluster->major_version) >= 1700)
253-
appendPQExpBufferStr(&pgoptions, " -c max_slot_wal_keep_size=-1");
261+
appendPQExpBufferStr(&pgoptions, " -c max_slot_wal_keep_size=-1 -c max_logical_replication_workers=0");
254262

255263
/* Use -b to disable autovacuum. */
256264
snprintf(cmd, sizeof(cmd),

0 commit comments

Comments
 (0)