Re: AlterSubscription_refresh "wrconn" wrong variable? - Mailing list pgsql-hackers

From Japin Li
Subject Re: AlterSubscription_refresh "wrconn" wrong variable?
Date
Msg-id MEYP282MB1669362E6FF3E063F453FD73B6589@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: AlterSubscription_refresh "wrconn" wrong variable?  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: AlterSubscription_refresh "wrconn" wrong variable?
List pgsql-hackers
On Thu, 06 May 2021 at 17:08, Peter Smith <smithpb2250@gmail.com> wrote:
> On Wed, May 5, 2021 at 12:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>> Peter Smith <smithpb2250@gmail.com> writes:
>> > This patch replaces the global "wrconn" in AlterSubscription_refresh with a local variable of the same name,
makingit consistent with other functions in subscriptioncmds.c (e.g. DropSubscription).
 
>> > The global wrconn is only meant to be used for logical apply/tablesync worker.
>> > Using the global/incorrect wrconn in AlterSubscription_refresh doesn't normally cause any problems, but harm is
stillposslble if the apply worker ever manages to do a subscription refresh. e.g. see [1]
 
>>
>> Hm.  I would actually place the blame for this on whoever thought
>> it was okay to name a global variable something as generic as
>> "wrconn".   Let's rename that while we're at it, say to something
>> like "tablesync_wrconn" (feel free to bikeshed).
>
> PSA v3 of the patch. Same as before, but now also renames the global
> variable from "wrconn" to "lrep_worker_wrconn".
>

Thanks for updating patch. I'm confused why we move the walrcv_connect() out of
PG_TRY() block?
+       /* Try to connect to the publisher. */
+       wrconn = walrcv_connect(sub->conninfo, true, sub->name, &err);
+       if (!wrconn)
+               ereport(ERROR,
+                               (errmsg("could not connect to the publisher: %s", err)));
+
        PG_TRY();
        {
-               /* Try to connect to the publisher. */
-               wrconn = walrcv_connect(sub->conninfo, true, sub->name, &err);
-               if (!wrconn)
-                       ereport(ERROR,
-                                       (errmsg("could not connect to the publisher: %s", err)));
-
                /* Get the table list from publisher. */
                pubrel_names = fetch_table_list(wrconn, sub->publications);

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: Asynchronous Append on postgres_fdw nodes.
Next
From: Amit Kapila
Date:
Subject: Re: Replication slot stats misgivings