Improve log message about termination of background workers.
authorFujii Masao <fujii@postgresql.org>
Mon, 30 Nov 2020 02:05:19 +0000 (11:05 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 30 Nov 2020 02:05:19 +0000 (11:05 +0900)
Previously the shutdown of a background worker that uses die() as
SIGTERM signal handler produced the log message "terminating
connection due to administrator command". This log message was
confusing because a background worker is not a connection.
This commit improves that log message to "terminating background
worker XXX due to administrator command" (XXX is replaced with
the name of the background worker). This is the same log message
as another SIGTERM signal handler bgworker_die() for a background
worker reports.

Author: Bharath Rupireddy
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/3f292fbb-f155-9a01-7cb2-7ccc9007ab3f@oss.nttdata.com

src/backend/tcop/postgres.c

index 34ed0e7558c46a07bf6017694ec49aec273ce5c0..3679799e50af8b7e62ec93b800693ed03be0a3a1 100644 (file)
@@ -3072,6 +3072,11 @@ ProcessInterrupts(void)
                     errmsg("terminating connection due to conflict with recovery"),
                     errdetail_recovery_conflict()));
        }
+       else if (IsBackgroundWorker)
+           ereport(FATAL,
+                   (errcode(ERRCODE_ADMIN_SHUTDOWN),
+                    errmsg("terminating background worker \"%s\" due to administrator command",
+                           MyBgworkerEntry->bgw_type)));
        else
            ereport(FATAL,
                    (errcode(ERRCODE_ADMIN_SHUTDOWN),