Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d8bd0a

Browse files
committed
Improve logical replication connection-failure messages.
These messages mostly said "could not connect to the publisher: %s"which is lacking context. Add some verbiage to indicate whichsubscription or worker process is failing.Nisha MoondDiscussion:https://postgr.es/m/CABdArM7q1=zqL++cYd0hVMg3u_tc0S=0Of=Um-KvDhLony0cSg@mail.gmail.com
1 parenta0f1fce commit0d8bd0a

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

‎src/backend/commands/subscriptioncmds.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
755755
if (!wrconn)
756756
ereport(ERROR,
757757
(errcode(ERRCODE_CONNECTION_FAILURE),
758-
errmsg("could not connect to the publisher: %s",err)));
758+
errmsg("subscription \"%s\" could not connect to the publisher: %s",
759+
stmt->subname,err)));
759760

760761
PG_TRY();
761762
{
@@ -888,7 +889,8 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data,
888889
if (!wrconn)
889890
ereport(ERROR,
890891
(errcode(ERRCODE_CONNECTION_FAILURE),
891-
errmsg("could not connect to the publisher: %s",err)));
892+
errmsg("subscription \"%s\" could not connect to the publisher: %s",
893+
sub->name,err)));
892894

893895
PG_TRY();
894896
{
@@ -1521,7 +1523,8 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
15211523
if (!wrconn)
15221524
ereport(ERROR,
15231525
(errcode(ERRCODE_CONNECTION_FAILURE),
1524-
errmsg("could not connect to the publisher: %s",err)));
1526+
errmsg("subscription \"%s\" could not connect to the publisher: %s",
1527+
sub->name,err)));
15251528

15261529
PG_TRY();
15271530
{

‎src/backend/replication/logical/slotsync.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,8 @@ ReplSlotSyncWorkerMain(char *startup_data, size_t startup_data_len)
14631463
if (!wrconn)
14641464
ereport(ERROR,
14651465
errcode(ERRCODE_CONNECTION_FAILURE),
1466-
errmsg("could not connect to the primary server: %s",err));
1466+
errmsg("synchronization worker \"%s\" could not connect to the primary server: %s",
1467+
app_name.data,err));
14671468

14681469
/*
14691470
* Register the disconnection callback.

‎src/backend/replication/logical/tablesync.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
13421342
if (LogRepWorkerWalRcvConn==NULL)
13431343
ereport(ERROR,
13441344
(errcode(ERRCODE_CONNECTION_FAILURE),
1345-
errmsg("could not connect to the publisher: %s",err)));
1345+
errmsg("table synchronization worker for subscription \"%s\" could not connect to the publisher: %s",
1346+
MySubscription->name,err)));
13461347

13471348
Assert(MyLogicalRepWorker->relstate==SUBREL_STATE_INIT||
13481349
MyLogicalRepWorker->relstate==SUBREL_STATE_DATASYNC||

‎src/backend/replication/logical/worker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4500,7 +4500,8 @@ run_apply_worker()
45004500
if (LogRepWorkerWalRcvConn==NULL)
45014501
ereport(ERROR,
45024502
(errcode(ERRCODE_CONNECTION_FAILURE),
4503-
errmsg("could not connect to the publisher: %s",err)));
4503+
errmsg("apply worker for subscription \"%s\" could not connect to the publisher: %s",
4504+
MySubscription->name,err)));
45044505

45054506
/*
45064507
* We don't really use the output identify_system for anything but it does

‎src/backend/replication/slotfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ pg_sync_replication_slots(PG_FUNCTION_ARGS)
898898
if (!wrconn)
899899
ereport(ERROR,
900900
errcode(ERRCODE_CONNECTION_FAILURE),
901-
errmsg("could not connect to the primary server: %s",err));
901+
errmsg("synchronization worker \"%s\" could not connect to the primary server: %s",
902+
app_name.data,err));
902903

903904
SyncReplicationSlots(wrconn);
904905

‎src/backend/replication/walreceiver.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
195195
char*err;
196196
char*sender_host=NULL;
197197
intsender_port=0;
198+
char*appname;
198199

199200
Assert(startup_data_len==0);
200201

@@ -298,13 +299,13 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
298299
sigprocmask(SIG_SETMASK,&UnBlockSig,NULL);
299300

300301
/* Establish the connection to the primary for XLOG streaming */
301-
wrconn=walrcv_connect(conninfo, true, false, false,
302-
cluster_name[0] ?cluster_name :"walreceiver",
303-
&err);
302+
appname=cluster_name[0] ?cluster_name :"walreceiver";
303+
wrconn=walrcv_connect(conninfo, true, false, false,appname,&err);
304304
if (!wrconn)
305305
ereport(ERROR,
306306
(errcode(ERRCODE_CONNECTION_FAILURE),
307-
errmsg("could not connect to the primary server: %s",err)));
307+
errmsg("streaming replication receiver \"%s\" could not connect to the primary server: %s",
308+
appname,err)));
308309

309310
/*
310311
* Save user-visible connection string. This clobbers the original

‎src/test/regress/expected/subscription.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ERROR: invalid connection string syntax: invalid connection option "i_dont_exis
139139
-- fail, connection string parses, but doesn't work (and does so without
140140
-- connecting, so this is reliable and safe)
141141
CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'port=-1' PUBLICATION testpub;
142-
ERROR: could not connect to the publisher: invalid port number: "-1"
142+
ERROR:subscription "regress_testsub5"could not connect to the publisher: invalid port number: "-1"
143143
-- fail - invalid connection string during ALTER
144144
ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar';
145145
ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp