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

From: Shubham Khanna <khannashubham1197(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided.
Date: 2025-03-22 13:56:09
Message-ID: CAHv8Rj+h+TLrr-Ttg_GS9=5Z2QY9FO1xR6XGGpPOgTr62rr1eA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 22, 2025 at 6:23 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> On Fri, 21 Mar 2025 at 18:59, Shubham Khanna
> <khannashubham1197(at)gmail(dot)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.
>

I agree that verifying the count of occurrences is a more
straightforward and effective approach, especially given the
challenges with pattern matching for $db1 and $db2 variables with
special names. This method simplifies validation and enhances
robustness by explicitly ensuring the expected number of logical
replication objects are created.

I have reviewed and merged the proposed changes into the patch. The
attached patches contain the suggested changes.

Thanks and regards,
Shubham Khanna.

Attachment Content-Type Size
v18-0003-Synopsis-for-all-option.patch application/octet-stream 1.5 KB
v18-0001-Enhance-pg_createsubscriber-to-fetch-and-append-.patch application/octet-stream 12.2 KB
v18-0002-Additional-test-cases.patch application/octet-stream 5.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-03-22 13:56:14 Improve error reporting for few options in pg_createsubscriber
Previous Message Andrew Dunstan 2025-03-22 13:28:41 Re: RFC: Additional Directory for Extensions