| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com> |
| Subject: | Prevent remote libpq notices from being sent to clients |
| Date: | 2026-06-05 09:31:31 |
| Message-ID: | 396C3BEE-CD4D-450A-8D28-E708E9AA4075@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
This is another issue with “[112faf137] Log remote NOTICE, WARNING, and similar messages using ereport()”. From the commit message, the intention of the feature is to log remote messages with ereport() to get better formatting:
```
Log remote NOTICE, WARNING, and similar messages using ereport().
Previously, NOTICE, WARNING, and similar messages received from remote
servers over replication, postgres_fdw, or dblink connections were printed
directly to stderr on the local server (e.g., the subscriber). As a result,
these messages lacked log prefixes (e.g., timestamp), making them harder
to trace and correlate with other log entries.
This commit addresses the issue by introducing a custom notice receiver
for replication, postgres_fdw, and dblink connections. These messages
are now logged via ereport(), ensuring they appear in the logs with proper
formatting and context, which improves clarity and aids in debugging.
```
So remote messages should only be output to the server log, but currently they can leak to the client if client_min_messages is set to log.
This is a simple repro:
```
evantest=# set client_min_messages=log;
SET
evantest=# select * from dblink('host=localhost dbname=postgres’,
'do $$ begin raise warning ''hello, client!!!''; end $$; select 1’)
as t(x int);
LOG: received message via remote connection: WARNING: hello, client!!!
x
---
1
(1 row)
```
The one-line fix is straightforward, just change the ereport() level from LOG to LOG_SERVER_ONLY. I also added a test in the patch.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Avoid-sending-remote-libpq-notices-back-to-client.patch | application/octet-stream | 3.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | wenhui qiu | 2026-06-05 09:32:47 | Re: Reduce LEFT/FULL JOIN to ANTI JOIN in more cases |
| Previous Message | Nitin Motiani | 2026-06-05 09:28:05 | Re: [PATCH] Fix for bug #19474: LIKE fails to match literal backslashes with nondeterministic collations |