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

Commit 08c3ad2

Browse files
committed
Rework how logirep launchers are stopped during pg_upgrade
This is a rework of 7021d3b, where we relied on forcing max_logical_replication_workers to 0 in the postgres command. This commit now prevents logical replication launchers to start using -b and a backend-side check based on IsBinaryUpgrade, effective when upgrading from 17 and newer versions. This commit improves the comments explaining why this restriction is necessary. This discussion was on hold until we were sure how to add support for subscribers in pg_upgrade, something now done thanks to 9a17be1. Reviewed-by: Álvaro Herrera, Amit Kapila, Tom Lane Discussion: https://postgr.es/m/ZU2TeVkUg5qEi7Oy@paquier.xyz
1 parent 7786af4 commit 08c3ad2

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/backend/replication/logical/launcher.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,14 @@ ApplyLauncherRegister(void)
925925
{
926926
BackgroundWorker bgw;
927927

928-
if (max_logical_replication_workers == 0)
928+
/*
929+
* The logical replication launcher is disabled during binary upgrades, to
930+
* prevent logical replication workers from running on the source cluster.
931+
* That could cause replication origins to move forward after having been
932+
* copied to the target cluster, potentially creating conflicts with the
933+
* copied data files.
934+
*/
935+
if (max_logical_replication_workers == 0 || IsBinaryUpgrade)
929936
return;
930937

931938
memset(&bgw, 0, sizeof(bgw));

src/bin/pg_upgrade/server.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,14 @@ 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.
259251
*/
260252
if (GET_MAJOR_VERSION(cluster->major_version) >= 1700)
261-
appendPQExpBufferStr(&pgoptions, " -c max_slot_wal_keep_size=-1 -c max_logical_replication_workers=0");
253+
appendPQExpBufferStr(&pgoptions, " -c max_slot_wal_keep_size=-1");
262254

263-
/* Use -b to disable autovacuum. */
255+
/*
256+
* Use -b to disable autovacuum and logical replication launcher
257+
* (effective in PG17 or later for the latter).
258+
*/
264259
snprintf(cmd, sizeof(cmd),
265260
"\"%s/pg_ctl\" -w -l \"%s/%s\" -D \"%s\" -o \"-p %d -b%s %s%s\" start",
266261
cluster->bindir,

0 commit comments

Comments
 (0)