diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-05-07 11:46:37 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-05-07 11:46:37 -0400 |
commit | 1803c76260006fb8b866bdc8112b9b51f0a32fef (patch) | |
tree | 8c0953852131bef782d2a051102046262e01f79b /src | |
parent | f414bd8e4efed6d7fd2a56789cdf56116539b595 (diff) | |
download | postgresql-1803c76260006fb8b866bdc8112b9b51f0a32fef.tar.gz postgresql-1803c76260006fb8b866bdc8112b9b51f0a32fef.zip |
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/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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/subscriptioncmds.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index e927b048d6e..f05e86fa936 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -507,6 +507,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; @@ -821,7 +822,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel) char originname[NAMEDATALEN]; char *err = NULL; RepOriginId originid; - WalReceiverConn *wrconn = NULL; + WalReceiverConn *wrconn; StringInfoData cmd; /* |