aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/parallel.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-04-08 14:55:14 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-04-08 14:55:14 -0400
commit9a374b77fb53e4cfbca121e4fa278a7d71bde7c4 (patch)
tree6591af757bd9df12549279b4b87f01e0ce98bd79 /src/bin/pg_dump/parallel.c
parent5c431c7fb327e1abc70b7a197650f8d45fd5bede (diff)
downloadpostgresql-9a374b77fb53e4cfbca121e4fa278a7d71bde7c4.tar.gz
postgresql-9a374b77fb53e4cfbca121e4fa278a7d71bde7c4.zip
Improve frontend error logging style.
Get rid of the separate "FATAL" log level, as it was applied so inconsistently as to be meaningless. This mostly involves s/pg_log_fatal/pg_log_error/g. Create a macro pg_fatal() to handle the common use-case of pg_log_error() immediately followed by exit(1). Various modules had already invented either this or equivalent macros; standardize on pg_fatal() and apply it where possible. Invent the ability to add "detail" and "hint" messages to a frontend message, much as we have long had in the backend. Except where rewording was needed to convert existing coding to detail/hint style, I have (mostly) resisted the temptation to change existing message wording. Patch by me. Design and patch reviewed at various stages by Robert Haas, Kyotaro Horiguchi, Peter Eisentraut and Daniel Gustafsson. Discussion: https://postgr.es/m/1363732.1636496441@sss.pgh.pa.us
Diffstat (limited to 'src/bin/pg_dump/parallel.c')
-rw-r--r--src/bin/pg_dump/parallel.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index bc5251be824..c9f6b86bb05 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -250,10 +250,7 @@ init_parallel_dump_utils(void)
/* Initialize socket access */
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (err != 0)
- {
- pg_log_error("%s() failed: error code %d", "WSAStartup", err);
- exit_nicely(1);
- }
+ pg_fatal("%s() failed: error code %d", "WSAStartup", err);
parallel_init_done = true;
}
@@ -393,7 +390,7 @@ archive_close_connection(int code, void *arg)
*
* Note that we don't expect to come here during normal exit (the workers
* should be long gone, and the ParallelState too). We're only here in a
- * fatal() situation, so intervening to cancel active commands is
+ * pg_fatal() situation, so intervening to cancel active commands is
* appropriate.
*/
static void
@@ -961,7 +958,7 @@ ParallelBackupStart(ArchiveHandle *AH)
/* Create communication pipes for this worker */
if (pgpipe(pipeMW) < 0 || pgpipe(pipeWM) < 0)
- fatal("could not create communication channels: %m");
+ pg_fatal("could not create communication channels: %m");
/* leader's ends of the pipes */
slot->pipeRead = pipeWM[PIPE_READ];
@@ -1018,7 +1015,7 @@ ParallelBackupStart(ArchiveHandle *AH)
else if (pid < 0)
{
/* fork failed */
- fatal("could not create worker process: %m");
+ pg_fatal("could not create worker process: %m");
}
/* In Leader after successful fork */
@@ -1148,8 +1145,8 @@ parseWorkerCommand(ArchiveHandle *AH, TocEntry **te, T_Action *act,
Assert(*te != NULL);
}
else
- fatal("unrecognized command received from leader: \"%s\"",
- msg);
+ pg_fatal("unrecognized command received from leader: \"%s\"",
+ msg);
}
/*
@@ -1191,8 +1188,8 @@ parseWorkerResponse(ArchiveHandle *AH, TocEntry *te,
AH->public.n_errors += n_errors;
}
else
- fatal("invalid message received from worker: \"%s\"",
- msg);
+ pg_fatal("invalid message received from worker: \"%s\"",
+ msg);
return status;
}
@@ -1323,10 +1320,10 @@ lockTableForWorker(ArchiveHandle *AH, TocEntry *te)
res = PQexec(AH->connection, query->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- fatal("could not obtain lock on relation \"%s\"\n"
- "This usually means that someone requested an ACCESS EXCLUSIVE lock "
- "on the table after the pg_dump parent process had gotten the "
- "initial ACCESS SHARE lock on the table.", qualId);
+ pg_fatal("could not obtain lock on relation \"%s\"\n"
+ "This usually means that someone requested an ACCESS EXCLUSIVE lock "
+ "on the table after the pg_dump parent process had gotten the "
+ "initial ACCESS SHARE lock on the table.", qualId);
PQclear(res);
destroyPQExpBuffer(query);
@@ -1412,7 +1409,7 @@ ListenToWorkers(ArchiveHandle *AH, ParallelState *pstate, bool do_wait)
{
/* If do_wait is true, we must have detected EOF on some socket */
if (do_wait)
- fatal("a worker process died unexpectedly");
+ pg_fatal("a worker process died unexpectedly");
return false;
}
@@ -1429,8 +1426,8 @@ ListenToWorkers(ArchiveHandle *AH, ParallelState *pstate, bool do_wait)
pstate->te[worker] = NULL;
}
else
- fatal("invalid message received from worker: \"%s\"",
- msg);
+ pg_fatal("invalid message received from worker: \"%s\"",
+ msg);
/* Free the string returned from getMessageFromWorker */
free(msg);
@@ -1534,7 +1531,7 @@ sendMessageToLeader(int pipefd[2], const char *str)
int len = strlen(str) + 1;
if (pipewrite(pipefd[PIPE_WRITE], str, len) != len)
- fatal("could not write to the communication channel: %m");
+ pg_fatal("could not write to the communication channel: %m");
}
/*
@@ -1611,7 +1608,7 @@ getMessageFromWorker(ParallelState *pstate, bool do_wait, int *worker)
}
if (i < 0)
- fatal("%s() failed: %m", "select");
+ pg_fatal("%s() failed: %m", "select");
for (i = 0; i < pstate->numWorkers; i++)
{
@@ -1652,7 +1649,7 @@ sendMessageToWorker(ParallelState *pstate, int worker, const char *str)
if (pipewrite(pstate->parallelSlot[worker].pipeWrite, str, len) != len)
{
- fatal("could not write to the communication channel: %m");
+ pg_fatal("could not write to the communication channel: %m");
}
}