Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided.

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Shubham Khanna <khannashubham1197(at)gmail(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Subject: Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided.
Date: 2025-02-10 16:44:01
Message-ID: CALDaNm2MtVAxNpre-WhcPSbY5JLCipRGGKxcnR0Lf0LytDOH3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 10 Feb 2025 at 20:36, Shubham Khanna
<khannashubham1197(at)gmail(dot)com> wrote:
>
> The attached patch contains the suggested changes.

If a new database is created on the primary server while
pg_createsubscriber is running, the subscription will not be created
for the new database.
To reproduce this issue, follow these steps:
Debug pg_createsubscriber and set a breakpoint after the
fetch_source_databases function, where the databases would have been
prepared.
While execution of pg_createsubscriber is paused, create a new
database on the primary node.
You will observe that the database is created on the standby node, but
the subscription will not be created for the newly created database.
+fetch_source_databases(struct CreateSubscriberOptions *opt)
+{
+ PGconn *conn;
+ PGresult *res;
+ int num_rows;
+
+ /* Establish a connection to the PostgreSQL server */
+ conn = connect_database(opt->pub_conninfo_str, true);
+
+ res = PQexec(conn, "SELECT datname FROM pg_database WHERE
datistemplate = false AND datallowconn = true");
+
+ /* Check for errors during query execution */
+ if (PQresultStatus(res) != PGRES_TUPLES_OK)

Regards,
Vignesh

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2025-02-10 17:17:42 Re: Expanding HOT updates for expression and partial indexes
Previous Message Andres Freund 2025-02-10 16:43:30 Re: WAL-logging facility for pgstats kinds