Re: speed up a logical replica setup

From: "Euler Taveira" <euler(at)eulerto(dot)com>
To: "vignesh C" <vignesh21(at)gmail(dot)com>
Cc: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Michael Paquier" <michael(at)paquier(dot)xyz>, "Peter Eisentraut" <peter(at)eisentraut(dot)org>, "Andres Freund" <andres(at)anarazel(dot)de>, "Ashutosh Bapat" <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, "Amit Kapila" <amit(dot)kapila16(at)gmail(dot)com>, "Shlok Kyal" <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
Subject: Re: speed up a logical replica setup
Date: 2024-03-07 04:43:02
Message-ID: d4268f63-c8b7-4de0-885f-91f868131326@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 6, 2024, at 8:24 AM, vignesh C wrote:
> Few comments:

Thanks for your review. Some changes are included in v26.

> 1) Can we use strdup here instead of atoi, as we do similarly in
> case of pg_dump too, else we will do double conversion, convert using
> atoi and again to string while forming the connection string:
> + case 'p':
> + if ((opt.sub_port = atoi(optarg)) <= 0)
> + pg_fatal("invalid subscriber
> port number");
> + break;

I don't have a strong preference but decided to provide a patch for it. See
v26-0003.

> 2) We can have some valid range for this, else we will end up in some
> unexpected values when a higher number is specified:
> + case 't':
> + opt.recovery_timeout = atoi(optarg);
> + break;

I wouldn't like to add an arbitrary value. Suggestions?

> 3) Now that we have addressed most of the items, can we handle this TODO:
> + /*
> + * TODO use primary_conninfo (if available) from subscriber and
> + * extract publisher connection string. Assume that there are
> + * identical entries for physical and logical
> replication. If there is
> + * not, we would fail anyway.
> + */
> + pg_log_error("no publisher connection string specified");
> + pg_log_error_hint("Try \"%s --help\" for more
> information.", progname);
> + exit(1);

It is not in my top priority at the moment.

> 4) By default the log level as info here, I was not sure how to set
> it to debug level to get these error messages:
> + pg_log_debug("publisher(%d): connection string: %s",
> i, dbinfo[i].pubconninfo);
> + pg_log_debug("subscriber(%d): connection string: %s",
> i, dbinfo[i].subconninfo);

<term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem>
<para>
Enables verbose mode. This will cause
<application>pg_createsubscriber</application> to output progress messages
and detailed information about each step to standard error.
Repeating the option causes additional debug-level messages to appear on
standard error.
</para>

> 5) Currently in non verbose mode there are no messages printed on
> console, we could have a few of them printed irrespective of verbose
> or not like the following:
> a) creating publication
> b) creating replication slot
> c) waiting for the target server to reach the consistent state
> d) If pg_createsubscriber fails after this point, you must recreate
> the physical replica before continuing.
> e) creating subscription

That's the idea. Quiet mode by default.

> 6) The message should be "waiting for the target server to reach the
> consistent state":
> +#define NUM_CONN_ATTEMPTS 5
> +
> + pg_log_info("waiting the target server to reach the consistent state");
> +
> + conn = connect_database(conninfo, true);

Fixed.

--
Euler Taveira
EDB https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2024-03-07 04:46:03 Re: Synchronizing slots from primary to standby
Previous Message Euler Taveira 2024-03-07 04:34:38 Re: speed up a logical replica setup