| From: | "Tristan Partin" <tristan(at)partin(dot)io> |
|---|---|
| To: | "Chao Li" <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com>, "vignesh C" <vignesh21(at)gmail(dot)com>, "Postgres hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Prevent remote libpq notices from being sent to clients |
| Date: | 2026-06-05 20:34:01 |
| Message-ID: | DJ1EI730WLNK.NJ6O9XYWV2R0@partin.io |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri Jun 5, 2026 at 9:32 AM UTC, Chao Li wrote:
> 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.
This looks good to me. Do you think we should also copy the test to
postgres_fdw? Or, I wonder if there is an even better location for the
test outside of either's regression suite.
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tristan Partin | 2026-06-05 20:46:00 | Re: dict_synonym.c: fix truncation of multibyte sequence |
| Previous Message | Daniel Gustafsson | 2026-06-05 20:22:16 | Re: [PATCH] Clarify that ssl_groups is for any key exchange groups |