aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2022-01-28 11:24:42 +0900
committerFujii Masao <fujii@postgresql.org>2022-01-28 11:25:45 +0900
commit6e7ee55e727771d97d0fce531a5cda350bb3fa84 (patch)
treeea388e9d1ddad0849932a0fa9a812d0bcfee6074
parentfb2f8e534aaefa649ada8df3e4863ebad32229f7 (diff)
downloadpostgresql-6e7ee55e727771d97d0fce531a5cda350bb3fa84.tar.gz
postgresql-6e7ee55e727771d97d0fce531a5cda350bb3fa84.zip
Prevent memory context logging from sending log message to connected client.
When pg_log_backend_memory_contexts() is executed, the target backend should use LOG_SERVER_ONLY to log its memory contexts, to prevent them from being sent to its connected client regardless of client_min_messages. But previously the backend unexpectedly used LOG to log the message "logging memory contexts of PID %d" and it could be sent to the client. This is a bug in memory context logging. To fix the bug, this commit changes that message so that it's logged with LOG_SERVER_ONLY. Back-patch to v14 where pg_log_backend_memory_contexts() was added. Author: Fujii Masao Reviewed-by: Bharath Rupireddy, Atsushi Torikoshi Discussion: https://postgr.es/m/82c12f36-86f7-5e72-79af-7f5c37f6cad7@oss.nttdata.com
-rw-r--r--src/backend/utils/mmgr/mcxt.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 6919a732804..a5f31e23a02 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -1042,8 +1042,14 @@ ProcessLogMemoryContextInterrupt(void)
{
LogMemoryContextPending = false;
- ereport(LOG,
- (errmsg("logging memory contexts of PID %d", MyProcPid)));
+ /*
+ * Use LOG_SERVER_ONLY to prevent this message from being sent to the
+ * connected client.
+ */
+ ereport(LOG_SERVER_ONLY,
+ (errhidestmt(true),
+ errhidecontext(true),
+ errmsg("logging memory contexts of PID %d", MyProcPid)));
/*
* When a backend process is consuming huge memory, logging all its memory