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

vignesh C <vignesh21@gmail.com>

From: vignesh C <vignesh21@gmail.com>
To: Shubham Khanna <khannashubham1197@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Nisha Moond <nisha.moond412@gmail.com>, Ajin Cherian <itsajin@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, Peter Smith <smithpb2250@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-03-22T12:53:45Z
Lists: pgsql-hackers

Attachments

On Fri, 21 Mar 2025 at 18:59, Shubham Khanna
<khannashubham1197@gmail.com> wrote:
>
>
> During the recent testing, I observed that the tests were failing when
> using wait_for_slot_catchup(). To address this, I reverted to using
> wait_for_subscription_sync(), which was employed previously and has
> proven to be more reliable in ensuring test stability.
> Please let me know if there are any additional adjustments you would
> suggest or if you would like me to investigate further into
> wait_for_slot_catchup().
>
> I have created a separate patch for the synopsis of '--all' option as
> suggested by Amit at [1]. The attached patch contains the suggested
> changes.

I believe you added the following because pattern matching is
difficult for the $db1 and $db2 variables having special names:
+# Create a new database on node_p
+$node_p->safe_psql(
+       "postgres", qq(
+       CREATE DATABASE db1;
+));

How about we change it to verify the count of occurrences instead for
this case like below:
# Verify that the required logical replication objects are created. The
# expected count 3 refers to postgres, $db1 and $db2 databases.
is(scalar(() = $stderr =~ /creating publication/g),
3, "verify publications are created for all databases");
is(scalar(() = $stderr =~ /creating the replication slot/g),
3, "verify replication slots are created for all databases");
is(scalar(() = $stderr =~ /creating subscription/g),
3, "verify subscriptions are created for all databases");

If you are ok, you can merge the changes attached.

Regards,
Vignesh

Commits

  1. Cosmetic fixes for pg_createsubscriber's -all option.

  2. pg_createsubscriber: Add '--all' option.