Improve style of some replication-related error messages.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 31 Mar 2021 19:25:53 +0000 (15:25 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 31 Mar 2021 19:25:53 +0000 (15:25 -0400)
Put the remote end's error message into the primary error string,
instead of relegating it to errdetail().  Although this could end up
being awkward if the remote sends us a really long error message,
it seems more in keeping with our message style guidelines, and more
helpful in situations where the errdetail could get dropped.

Peter Smith

Discussion: https://postgr.es/m/CAHut+Ps-Qv2yQceCwobQDP0aJOkfDzRFrOaR6+2Op2K=WHGeWg@mail.gmail.com

src/backend/commands/subscriptioncmds.c
src/backend/replication/logical/tablesync.c

index bfd3514546a54b1e33815d23100ee586babdaaa8..5282b797359eb7a7d53579027b5a97d97671492c 100644 (file)
@@ -1320,17 +1320,15 @@ ReplicationSlotDropAtPubNode(WalReceiverConn *wrconn, char *slotname, bool missi
                {
                        /* LOG. Error, but missing_ok = true. */
                        ereport(LOG,
-                                       (errmsg("could not drop the replication slot \"%s\" on publisher",
-                                                       slotname),
-                                        errdetail("The error was: %s", res->err)));
+                                       (errmsg("could not drop replication slot \"%s\" on publisher: %s",
+                                                       slotname, res->err)));
                }
                else
                {
                        /* ERROR. */
                        ereport(ERROR,
-                                       (errmsg("could not drop the replication slot \"%s\" on publisher",
-                                                       slotname),
-                                        errdetail("The error was: %s", res->err)));
+                                       (errmsg("could not drop replication slot \"%s\" on publisher: %s",
+                                                       slotname, res->err)));
                }
 
                walrcv_clear_result(res);
@@ -1545,8 +1543,7 @@ ReportSlotConnectionError(List *rstates, Oid subid, char *slotname, char *err)
 
        ereport(ERROR,
                        (errmsg("could not connect to publisher when attempting to "
-                                       "drop the replication slot \"%s\"", slotname),
-                        errdetail("The error was: %s", err),
+                                       "drop replication slot \"%s\": %s", slotname, err),
        /* translator: %s is an SQL ALTER command */
                         errhint("Use %s to disassociate the subscription from the slot.",
                                         "ALTER SUBSCRIPTION ... SET (slot_name = NONE)")));
index 8494db8f0537bac6252ea34d8a2893bc9b3094fb..0638f5c7f8768a5b5c75b5c47fe0272e2028510f 100644 (file)
@@ -1043,8 +1043,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
                                          0, NULL);
        if (res->status != WALRCV_OK_COMMAND)
                ereport(ERROR,
-                               (errmsg("table copy could not start transaction on publisher"),
-                                errdetail("The error was: %s", res->err)));
+                               (errmsg("table copy could not start transaction on publisher: %s",
+                                               res->err)));
        walrcv_clear_result(res);
 
        /*
@@ -1103,8 +1103,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
        res = walrcv_exec(wrconn, "COMMIT", 0, NULL);
        if (res->status != WALRCV_OK_COMMAND)
                ereport(ERROR,
-                               (errmsg("table copy could not finish transaction on publisher"),
-                                errdetail("The error was: %s", res->err)));
+                               (errmsg("table copy could not finish transaction on publisher: %s",
+                                               res->err)));
        walrcv_clear_result(res);
 
        table_close(rel, NoLock);