public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tristan Partin <[email protected]>
To: Chao Li <[email protected]>
Cc: Fujii Masao <[email protected]>
Cc: vignesh C <[email protected]>
Cc: Postgres hackers <[email protected]>
Subject: Re: Prevent remote libpq notices from being sent to clients
Date: Fri, 05 Jun 2026 20:34:01 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

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)






view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Prevent remote libpq notices from being sent to clients
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox