public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: [email protected]
Subject: pg_upgradecluster and synchronous replication
Date: Wed, 14 Jan 2026 18:50:00 +0100
Message-ID: <[email protected]> (raw)

I ran into a problem today during a training session when I demonstrated

  pg_upgradecluster -v 18 --method=upgrade --link 17 main

The problem was that I had configured synchronous streaming replication first, so after
pg_upgrade, the synchronous standby was lost, and when pg_upgradecluster ran

  vacuumdb ... --analyze-in-stages --missing-stats-only

processing hung, because the synchronous standby was not available and the transaction
could not commit.

Yes, that was my mistake, and yes, the problem was easily fixed by interrupting
pg_upgradecluster, disabling synchronous_standby_names and running the ANALYZE
and v17 cluster removal manually.

Yet I wonder if pg_upgradecluster could improve things by disabling synchronous_standby_names
when the cluster ist started for the "finish" stage.  I have attached a POC patch how this
could be done.  I didn't test it, and my Perl skills are marginal, but you get the idea.

Perhaps this is too much black magic, not sure.  But I wanted to share my experience.

Yours,
Laurenz Albe


Attachments:

  [text/x-patch] pg_upgradecluster-analyze.patch (672B, 2-pg_upgradecluster-analyze.patch)
  download | inline diff:
diff --git a/pg_upgradecluster b/pg_upgradecluster
index 09979c3..1698ba8 100755
--- a/pg_upgradecluster
+++ b/pg_upgradecluster
@@ -743,7 +743,7 @@ if (not exists $ENV{'PG_CLUSTER_CONF_ROOT'} and -d '/run/systemd/system' and $>
 $start = ($info{running} or $upgrade_scripts) if ($start == -1);
 if ($start) {
     print "Starting upgraded cluster on port $newinfo{port}...\n";
-    @argv = ('pg_ctlcluster', $newversion, $newcluster, 'start');
+    @argv = ('pg_ctlcluster', $newversion, $newcluster, 'start', '--', '-o', "\"-csynchronous_standby_names=''\"");
     error "Could not start upgraded cluster; please check configuration and log files" if system @argv;
 }
 


view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pg_upgradecluster and synchronous replication
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox