Content-Length: 15538 | pFad | https://postgr.es/c/cfebc7080

git.postgresql.org Git - postgresql.git/commitdiff
AlterSubscription_refresh: avoid stomping on global variable
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 7 May 2021 15:46:37 +0000 (11:46 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 7 May 2021 15:46:37 +0000 (11:46 -0400)
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/20201111215820.qihhrz7fayu6myfi@alap3.anarazel.de

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 <peter.b.smith@fujitsu.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/CAHut+Pu7Jv9L2BOEx_Z0UtJxfDevQSAUW2mJqWU+CtmDrEZVAg@mail.gmail.com

src/backend/commands/subscriptioncmds.c

index aa88092f3a400ffb92498dbf71649998be70223c..5b02e0de0fb60309e98aa11c5b2224b38925f869 100644 (file)
@@ -530,6 +530,7 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
    List       *subrel_states;
    Oid        *subrel_local_oids;
    Oid        *pubrel_local_oids;
+   WalReceiverConn *wrconn;
    ListCell   *lc;
    int         off;
 
@@ -848,7 +849,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
    char        origenname[NAMEDATALEN];
    char       *err = NULL;
    RepOriginId origenid;
-   WalReceiverConn *wrconn = NULL;
+   WalReceiverConn *wrconn;
    StringInfoData cmd;
    Form_pg_subscription form;
 








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://postgr.es/c/cfebc7080

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy