From: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
---|---|
To: | 'vignesh C' <vignesh21(at)gmail(dot)com>, Shubham Khanna <khannashubham1197(at)gmail(dot)com> |
Cc: | 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-18 00:52:15 |
Message-ID: | OSCPR01MB1496612E493CC09458D93FD9AF5FA2@OSCPR01MB14966.jpnprd01.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Dear Vignesh,
> > 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)
>
> If we don't have a solution for this, how about the following approach:
> a) Add a note in the documentation indicating that the publication and
> subscriptions must be created manually for any new databases created
> while pg_createsubscriber is running. b) At the end of the
> pg_createsubscriber execution, identify any new databases that were
> created and list them for the user.
>
> Since this scenario might not be common, we could either implement
> just option a) or both a) and b).
I'm not sure we must really handle the case. Documentation [1] has already described
not to run DDL commands during the command:
```
Since DDL commands are not replicated by logical replication, avoid executing DDL
commands that change the database schema while running pg_createsubscriber.
If the target server has already been converted to logical replica, the DDL commands
might not be replicated, which might cause an error.
```
Thought?
[1]: https://www.postgresql.org/docs/devel/app-pgcreatesubscriber.html
Best regards,
Hayato Kuroda
FUJITSU LIMITED
From | Date | Subject | |
---|---|---|---|
Next Message | Kyotaro Horiguchi | 2025-02-18 01:32:40 | Inconsistent GUC descriptions |
Previous Message | Michael Paquier | 2025-02-18 00:49:22 | Re: Proposal to CREATE FOREIGN TABLE LIKE |