Fix untranslatable log message assembly

We can't inject the name of the logical replication worker into a log
message like that.  But for these messages we don't really need the
precision of knowing what kind of worker it was, so just write
"logical replication worker" and keep the message in one piece.

Discussion: https://www.postgresql.org/message-id/flat/CAHut%2BPt1xwATviPGjjtJy5L631SGf3qjV9XUCmxLu16cHamfgg%40mail.gmail.com
This commit is contained in:
Peter Eisentraut 2023-07-13 12:56:35 +02:00
parent 4946910a87
commit b4018ecb88
1 changed files with 12 additions and 32 deletions

View File

@ -435,20 +435,6 @@ static inline void reset_apply_error_context_info(void);
static TransApplyAction get_transaction_apply_action(TransactionId xid, static TransApplyAction get_transaction_apply_action(TransactionId xid,
ParallelApplyWorkerInfo **winfo); ParallelApplyWorkerInfo **winfo);
/*
* Return the name of the logical replication worker.
*/
static const char *
get_worker_name(void)
{
if (am_tablesync_worker())
return _("logical replication table synchronization worker");
else if (am_parallel_apply_worker())
return _("logical replication parallel apply worker");
else
return _("logical replication apply worker");
}
/* /*
* Form the origin name for the subscription. * Form the origin name for the subscription.
* *
@ -3904,9 +3890,8 @@ maybe_reread_subscription(void)
if (!newsub) if (!newsub)
{ {
ereport(LOG, ereport(LOG,
/* translator: first %s is the name of logical replication worker */ (errmsg("logical replication worker for subscription \"%s\" will stop because the subscription was removed",
(errmsg("%s for subscription \"%s\" will stop because the subscription was removed", MySubscription->name)));
get_worker_name(), MySubscription->name)));
/* Ensure we remove no-longer-useful entry for worker's start time */ /* Ensure we remove no-longer-useful entry for worker's start time */
if (!am_tablesync_worker() && !am_parallel_apply_worker()) if (!am_tablesync_worker() && !am_parallel_apply_worker())
@ -3918,9 +3903,8 @@ maybe_reread_subscription(void)
if (!newsub->enabled) if (!newsub->enabled)
{ {
ereport(LOG, ereport(LOG,
/* translator: first %s is the name of logical replication worker */ (errmsg("logical replication worker for subscription \"%s\" will stop because the subscription was disabled",
(errmsg("%s for subscription \"%s\" will stop because the subscription was disabled", MySubscription->name)));
get_worker_name(), MySubscription->name)));
apply_worker_exit(); apply_worker_exit();
} }
@ -3954,9 +3938,8 @@ maybe_reread_subscription(void)
MySubscription->name))); MySubscription->name)));
else else
ereport(LOG, ereport(LOG,
/* translator: first %s is the name of logical replication worker */ (errmsg("logical replication worker for subscription \"%s\" will restart because of a parameter change",
(errmsg("%s for subscription \"%s\" will restart because of a parameter change", MySubscription->name)));
get_worker_name(), MySubscription->name)));
apply_worker_exit(); apply_worker_exit();
} }
@ -4478,9 +4461,8 @@ InitializeApplyWorker(void)
if (!MySubscription) if (!MySubscription)
{ {
ereport(LOG, ereport(LOG,
/* translator: %s is the name of logical replication worker */ (errmsg("logical replication worker for subscription %u will not start because the subscription was removed during startup",
(errmsg("%s for subscription %u will not start because the subscription was removed during startup", MyLogicalRepWorker->subid)));
get_worker_name(), MyLogicalRepWorker->subid)));
/* Ensure we remove no-longer-useful entry for worker's start time */ /* Ensure we remove no-longer-useful entry for worker's start time */
if (!am_tablesync_worker() && !am_parallel_apply_worker()) if (!am_tablesync_worker() && !am_parallel_apply_worker())
@ -4494,9 +4476,8 @@ InitializeApplyWorker(void)
if (!MySubscription->enabled) if (!MySubscription->enabled)
{ {
ereport(LOG, ereport(LOG,
/* translator: first %s is the name of logical replication worker */ (errmsg("logical replication worker for subscription \"%s\" will not start because the subscription was disabled during startup",
(errmsg("%s for subscription \"%s\" will not start because the subscription was disabled during startup", MySubscription->name)));
get_worker_name(), MySubscription->name)));
apply_worker_exit(); apply_worker_exit();
} }
@ -4517,9 +4498,8 @@ InitializeApplyWorker(void)
get_rel_name(MyLogicalRepWorker->relid)))); get_rel_name(MyLogicalRepWorker->relid))));
else else
ereport(LOG, ereport(LOG,
/* translator: first %s is the name of logical replication worker */ (errmsg("logical replication apply worker for subscription \"%s\" has started",
(errmsg("%s for subscription \"%s\" has started", MySubscription->name)));
get_worker_name(), MySubscription->name)));
CommitTransactionCommand(); CommitTransactionCommand();
} }