1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

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 which
subscription or worker process is failing.

Nisha Moond

Discussion: https://postgr.es/m/CABdArM7q1=zqL++cYd0hVMg3u_tc0S=0Of=Um-KvDhLony0cSg@mail.gmail.com
This commit is contained in:
Tom Lane
2024-07-11 13:21:13 -04:00
parent a0f1fce80c
commit 0d8bd0a72e
7 changed files with 20 additions and 12 deletions

View File

@ -1463,7 +1463,8 @@ ReplSlotSyncWorkerMain(char *startup_data, size_t startup_data_len)
if (!wrconn)
ereport(ERROR,
errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("could not connect to the primary server: %s", err));
errmsg("synchronization worker \"%s\" could not connect to the primary server: %s",
app_name.data, err));
/*
* Register the disconnection callback.

View File

@ -1342,7 +1342,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
if (LogRepWorkerWalRcvConn == NULL)
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("could not connect to the publisher: %s", err)));
errmsg("table synchronization worker for subscription \"%s\" could not connect to the publisher: %s",
MySubscription->name, err)));
Assert(MyLogicalRepWorker->relstate == SUBREL_STATE_INIT ||
MyLogicalRepWorker->relstate == SUBREL_STATE_DATASYNC ||

View File

@ -4500,7 +4500,8 @@ run_apply_worker()
if (LogRepWorkerWalRcvConn == NULL)
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("could not connect to the publisher: %s", err)));
errmsg("apply worker for subscription \"%s\" could not connect to the publisher: %s",
MySubscription->name, err)));
/*
* We don't really use the output identify_system for anything but it does

View File

@ -898,7 +898,8 @@ pg_sync_replication_slots(PG_FUNCTION_ARGS)
if (!wrconn)
ereport(ERROR,
errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("could not connect to the primary server: %s", err));
errmsg("synchronization worker \"%s\" could not connect to the primary server: %s",
app_name.data, err));
SyncReplicationSlots(wrconn);

View File

@ -195,6 +195,7 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
char *err;
char *sender_host = NULL;
int sender_port = 0;
char *appname;
Assert(startup_data_len == 0);
@ -298,13 +299,13 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
/* Establish the connection to the primary for XLOG streaming */
wrconn = walrcv_connect(conninfo, true, false, false,
cluster_name[0] ? cluster_name : "walreceiver",
&err);
appname = cluster_name[0] ? cluster_name : "walreceiver";
wrconn = walrcv_connect(conninfo, true, false, false, appname, &err);
if (!wrconn)
ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("could not connect to the primary server: %s", err)));
errmsg("streaming replication receiver \"%s\" could not connect to the primary server: %s",
appname, err)));
/*
* Save user-visible connection string. This clobbers the original