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)