AlterSubscription_refresh: avoid stomping on global variable

This patch replaces use of the global "wrconn" variable 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.
Abusing it this way is known to cause trouble if an apply worker
manages to do a subscription refresh, such as reported by Jeremy Finzel
and diagnosed by Andres Freund back in November 2020, at
https://www.postgresql.org/message-id/[email protected]

Backpatch to 10.  In branch master, also move the connection establishment
to occur outside the PG_TRY block; this way we can remove a test for NULL in
PG_FINALLY, and it also makes the code more consistent with similar code in
the same file.

Author: Peter Smith <[email protected]>
Reviewed-by: Bharath Rupireddy <[email protected]>
Reviewed-by: Japin Li <[email protected]>
Discussion: 
https://postgr.es/m/cahut+pu7jv9l2boex_z0utjxfdevqsauw2mjqwu+ctmdrez...@mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ef70b6f8e28dae452d2bdb379204db234c930d26

Modified Files
--------------
src/backend/commands/subscriptioncmds.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Reply via email to