Re: pg_upgrade and logical replication
Peter Smith <smithpb2250@gmail.com>
From: Peter Smith <smithpb2250@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
Julien Rouhaud <rjuju123@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Amit Kapila <amit.kapila16@gmail.com>
Date: 2023-11-13T08:21:39Z
Lists: pgsql-hackers
Here are some review comments for patch v13-0001
======
src/bin/pg_dump/pg_dump.c
1. getSubscriptionTables
+ int i_srsublsn;
+ int i;
+ int cur_rel = 0;
+ int ntups;
What is the difference between 'i' and 'cur_rel'?
AFAICT these represent the same tuple index, in which case you might
as well throw away 'cur_rel' and only keep 'i'.
~~~
2. getSubscriptionTables
+ for (i = 0; i < ntups; i++)
+ {
+ Oid cur_srsubid = atooid(PQgetvalue(res, i, i_srsubid));
+ Oid relid = atooid(PQgetvalue(res, i, i_srrelid));
+ TableInfo *tblinfo;
Since this is all new code, using C99 style for loop variable
declaration of 'i' will be better.
======
src/bin/pg_upgrade/check.c
3. check_for_subscription_state
+check_for_subscription_state(ClusterInfo *cluster)
+{
+ int dbnum;
+ FILE *script = NULL;
+ char output_path[MAXPGPATH];
+ int ntup;
+
+ /* Subscription relations state can be migrated since PG17. */
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 1700)
+ return;
+
+ prep_status("Checking for subscription state");
+
+ snprintf(output_path, sizeof(output_path), "%s/%s",
+ log_opts.basedir,
+ "subscription_state.txt");
I felt this filename ought to be more like
'subscriptions_with_bad_state.txt' because the current name looks like
a normal logfile with nothing to indicate that it is only for the
states of the "bad" subscriptions.
~~~
4.
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
Since this is all new code, using C99 style for loop variable
declaration of 'dbnum' will be better.
~~~
5.
+ * a) SUBREL_STATE_DATASYNC:A relation upgraded while in this state
+ * would retain a replication slot, which could not be dropped by the
+ * sync worker spawned after the upgrade because the subscription ID
+ * tracked by the publisher does not match anymore.
missing whitespace
/SUBREL_STATE_DATASYNC:A relation/SUBREL_STATE_DATASYNC: A relation/
======
Kind Regards,
Peter Smith.
Fujitsu Australia
Commits
-
pg_upgrade: Retrieve subscription count more efficiently.
- 73de50e13e39 17.0 landed
- 364509a2e7f9 18.0 landed
-
Fix random failure in 004_subscription.
- 677a45c4ae16 17.0 landed
-
Fix 004_subscription.pl to allow its usage in --link mode.
- f17529b71097 17.0 landed
-
Allow upgrades to preserve the full subscription's state.
- 9a17be1e244a 17.0 landed
-
Prevent startup of logical replication launcher during pg_upgrade
- 7021d3b17664 17.0 landed