Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e5c071b

Browse files
committed
Rename the logical replication global "wrconn"
The worker.c global wrconn is only meant to be used by logical apply/ tablesync workers, but there are other variables with the same name. To reduce future confusion rename the global from "wrconn" to "LogRepWorkerWalRcvConn". While this is just cosmetic, it seems better to backpatch it all the way back to 10 where this code appeared, to avoid future backpatching issues. Author: Peter Smith <smithpb2250@gmail.com> Discussion: https://postgr.es/m/CAHut+Pu7Jv9L2BOEx_Z0UtJxfDevQSAUW2mJqWU+CtmDrEZVAg@mail.gmail.com
1 parent 834d928 commit e5c071b

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

src/backend/replication/logical/launcher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ static void
704704
logicalrep_worker_onexit(int code, Datum arg)
705705
{
706706
/* Disconnect gracefully from the remote side. */
707-
if (wrconn)
708-
walrcv_disconnect(wrconn);
707+
if (LogRepWorkerWalRcvConn)
708+
walrcv_disconnect(LogRepWorkerWalRcvConn);
709709

710710
logicalrep_worker_detach();
711711

src/backend/replication/logical/tablesync.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ process_syncing_tables_for_sync(XLogRecPtr current_lsn)
288288
MyLogicalRepWorker->relstate,
289289
MyLogicalRepWorker->relstate_lsn);
290290

291-
walrcv_endstreaming(wrconn, &tli);
291+
walrcv_endstreaming(LogRepWorkerWalRcvConn, &tli);
292292
finish_sync_worker();
293293
}
294294
else
@@ -584,7 +584,7 @@ copy_read_data(void *outbuf, int minread, int maxread)
584584
for (;;)
585585
{
586586
/* Try read the data. */
587-
len = walrcv_receive(wrconn, &buf, &fd);
587+
len = walrcv_receive(LogRepWorkerWalRcvConn, &buf, &fd);
588588

589589
CHECK_FOR_INTERRUPTS();
590590

@@ -657,7 +657,8 @@ fetch_remote_table_info(char *nspname, char *relname,
657657
" AND c.relname = %s",
658658
quote_literal_cstr(nspname),
659659
quote_literal_cstr(relname));
660-
res = walrcv_exec(wrconn, cmd.data, lengthof(tableRow), tableRow);
660+
res = walrcv_exec(LogRepWorkerWalRcvConn, cmd.data,
661+
lengthof(tableRow), tableRow);
661662

662663
if (res->status != WALRCV_OK_TUPLES)
663664
ereport(ERROR,
@@ -695,9 +696,11 @@ fetch_remote_table_info(char *nspname, char *relname,
695696
" AND a.attrelid = %u"
696697
" ORDER BY a.attnum",
697698
lrel->remoteid,
698-
(walrcv_server_version(wrconn) >= 120000 ? "AND a.attgenerated = ''" : ""),
699+
(walrcv_server_version(LogRepWorkerWalRcvConn) >= 120000 ?
700+
"AND a.attgenerated = ''" : ""),
699701
lrel->remoteid);
700-
res = walrcv_exec(wrconn, cmd.data, lengthof(attrRow), attrRow);
702+
res = walrcv_exec(LogRepWorkerWalRcvConn, cmd.data,
703+
lengthof(attrRow), attrRow);
701704

702705
if (res->status != WALRCV_OK_TUPLES)
703706
ereport(ERROR,
@@ -784,7 +787,7 @@ copy_table(Relation rel)
784787
appendStringInfo(&cmd, " FROM %s) TO STDOUT",
785788
quote_qualified_identifier(lrel.nspname, lrel.relname));
786789
}
787-
res = walrcv_exec(wrconn, cmd.data, 0, NULL);
790+
res = walrcv_exec(LogRepWorkerWalRcvConn, cmd.data, 0, NULL);
788791
pfree(cmd.data);
789792
if (res->status != WALRCV_OK_COPY_OUT)
790793
ereport(ERROR,
@@ -851,8 +854,9 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
851854
* application_name, so that it is different from the main apply worker,
852855
* so that synchronous replication can distinguish them.
853856
*/
854-
wrconn = walrcv_connect(MySubscription->conninfo, true, slotname, &err);
855-
if (wrconn == NULL)
857+
LogRepWorkerWalRcvConn = walrcv_connect(MySubscription->conninfo, true,
858+
slotname, &err);
859+
if (LogRepWorkerWalRcvConn == NULL)
856860
ereport(ERROR,
857861
(errmsg("could not connect to the publisher: %s", err)));
858862

@@ -897,7 +901,7 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
897901
* inside the transaction so that we can use the snapshot made
898902
* by the slot to get existing data.
899903
*/
900-
res = walrcv_exec(wrconn,
904+
res = walrcv_exec(LogRepWorkerWalRcvConn,
901905
"BEGIN READ ONLY ISOLATION LEVEL "
902906
"REPEATABLE READ", 0, NULL);
903907
if (res->status != WALRCV_OK_COMMAND)
@@ -914,14 +918,14 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
914918
* that is consistent with the lsn used by the slot to start
915919
* decoding.
916920
*/
917-
walrcv_create_slot(wrconn, slotname, true,
921+
walrcv_create_slot(LogRepWorkerWalRcvConn, slotname, true,
918922
CRS_USE_SNAPSHOT, origin_startpos);
919923

920924
PushActiveSnapshot(GetTransactionSnapshot());
921925
copy_table(rel);
922926
PopActiveSnapshot();
923927

924-
res = walrcv_exec(wrconn, "COMMIT", 0, NULL);
928+
res = walrcv_exec(LogRepWorkerWalRcvConn, "COMMIT", 0, NULL);
925929
if (res->status != WALRCV_OK_COMMAND)
926930
ereport(ERROR,
927931
(errmsg("table copy could not finish transaction on publisher"),

src/backend/replication/logical/worker.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ typedef struct SlotErrCallbackArg
100100
static MemoryContext ApplyMessageContext = NULL;
101101
MemoryContext ApplyContext = NULL;
102102

103-
WalReceiverConn *wrconn = NULL;
103+
WalReceiverConn *LogRepWorkerWalRcvConn = NULL;
104104

105105
Subscription *MySubscription = NULL;
106106
bool MySubscriptionValid = false;
@@ -1517,7 +1517,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
15171517

15181518
MemoryContextSwitchTo(ApplyMessageContext);
15191519

1520-
len = walrcv_receive(wrconn, &buf, &fd);
1520+
len = walrcv_receive(LogRepWorkerWalRcvConn, &buf, &fd);
15211521

15221522
if (len != 0)
15231523
{
@@ -1597,7 +1597,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
15971597
MemoryContextReset(ApplyMessageContext);
15981598
}
15991599

1600-
len = walrcv_receive(wrconn, &buf, &fd);
1600+
len = walrcv_receive(LogRepWorkerWalRcvConn, &buf, &fd);
16011601
}
16021602
}
16031603

@@ -1627,7 +1627,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
16271627
{
16281628
TimeLineID tli;
16291629

1630-
walrcv_endstreaming(wrconn, &tli);
1630+
walrcv_endstreaming(LogRepWorkerWalRcvConn, &tli);
16311631
break;
16321632
}
16331633

@@ -1790,7 +1790,8 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply)
17901790
(uint32) (flushpos >> 32), (uint32) flushpos
17911791
);
17921792

1793-
walrcv_send(wrconn, reply_message->data, reply_message->len);
1793+
walrcv_send(LogRepWorkerWalRcvConn,
1794+
reply_message->data, reply_message->len);
17941795

17951796
if (recvpos > last_recvpos)
17961797
last_recvpos = recvpos;
@@ -2088,17 +2089,17 @@ ApplyWorkerMain(Datum main_arg)
20882089
origin_startpos = replorigin_session_get_progress(false);
20892090
CommitTransactionCommand();
20902091

2091-
wrconn = walrcv_connect(MySubscription->conninfo, true, MySubscription->name,
2092-
&err);
2093-
if (wrconn == NULL)
2092+
LogRepWorkerWalRcvConn = walrcv_connect(MySubscription->conninfo, true,
2093+
MySubscription->name, &err);
2094+
if (LogRepWorkerWalRcvConn == NULL)
20942095
ereport(ERROR,
20952096
(errmsg("could not connect to the publisher: %s", err)));
20962097

20972098
/*
20982099
* We don't really use the output identify_system for anything but it
20992100
* does some initializations on the upstream so let's still call it.
21002101
*/
2101-
(void) walrcv_identify_system(wrconn, &startpointTLI);
2102+
(void) walrcv_identify_system(LogRepWorkerWalRcvConn, &startpointTLI);
21022103
}
21032104

21042105
/*
@@ -2117,7 +2118,7 @@ ApplyWorkerMain(Datum main_arg)
21172118
options.proto.logical.publication_names = MySubscription->publications;
21182119

21192120
/* Start normal logical streaming replication. */
2120-
walrcv_startstreaming(wrconn, &options);
2121+
walrcv_startstreaming(LogRepWorkerWalRcvConn, &options);
21212122

21222123
/* Run the main loop. */
21232124
LogicalRepApplyLoop(origin_startpos);

src/include/replication/worker_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct LogicalRepWorker
6060
extern MemoryContext ApplyContext;
6161

6262
/* libpqreceiver connection */
63-
extern struct WalReceiverConn *wrconn;
63+
extern struct WalReceiverConn *LogRepWorkerWalRcvConn;
6464

6565
/* Worker and subscription objects. */
6666
extern Subscription *MySubscription;

0 commit comments

Comments
 (0)