Re: AlterSubscription_refresh "wrconn" wrong variable?
Japin Li <japinli@hotmail.com>
From: Japin Li <japinli@hotmail.com>
To: Peter Smith <smithpb2250@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com>,
pgsql-hackers@lists.postgresql.org
Date: 2021-05-06T09:17:59Z
Lists: 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, making it 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 still posslble 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.
Commits
-
Rename the logical replication global "wrconn"
- e5c071bc0f93 13.4 landed
- db16c656478b 14.0 landed
- b5b7cba7643c 10.18 landed
- b0e6e08b1981 11.13 landed
- 6e9723cde5c6 12.8 landed
-
AlterSubscription_refresh: avoid stomping on global variable
- ef70b6f8e28d 13.3 landed
- cfebc7080c99 12.7 landed
- b40865ebd41a 11.12 landed
- 4e8c0f1a0d0d 14.0 landed
- 1803c7626000 10.17 landed
-
Logical replication support for initial data copy
- 7c4f52409a8c 10.0 cited