log_level_pg_log_backend_memory_contexts_v1.patch

text/plain

Filename: log_level_pg_log_backend_memory_contexts_v1.patch
Type: text/plain
Part: 0
Message: pg_log_backend_memory_contexts() and log level

Patch

Format: unified
Series: patch v1
File+
src/backend/utils/mmgr/mcxt.c 8 2
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 2876f6868c..e12be1b9bd 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