Re: Logging which local address was connected to in log_line_prefix

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: david(at)pgmasters(dot)net, Peter Eisentraut <peter(at)eisentraut(dot)org>, Cary Huang <cary(dot)huang(at)highgo(dot)ca>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Logging which local address was connected to in log_line_prefix
Date: 2025-03-02 18:26:10
Message-ID: 990a60e3-f87b-441f-8689-b87521496beb@uni-muenster.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 27.02.25 14:54, Greg Sabino Mullane wrote:
> Great question. I think "supposed to" is a bit of a stretch, but I
> presume it's the difference between a client connecting and using its
> connection information versus an already existing backend process,
> which is always going to be "local".
>
> Overall this makes sense, as that checkpoint example above is coming
> from the checkpointer background process at 3114981, not the backend
> process that happened to trigger it. And 3114981 has no way of knowing
> the details of the caller's connection.
>
In that case, it LGTM.

I revisited this patch and tested it with two different computers (for
client and server).

Initially, I was momentarily confused by the logged address format,
which varies depending on the client's format. However, I found that %h
behaves just like this, so I guess it is ok.

postgres=# SHOW log_line_prefix;
    log_line_prefix    
-----------------------
 %m [%p]:  L=%L, h=%h
(1 row)

2025-03-02 18:19:07.859 CET [2246150]:  L=192.168.178.27,
h=192.168.178.79 ERROR:  division by zero
2025-03-02 18:19:07.859 CET [2246150]:  L=192.168.178.27,
h=192.168.178.79 STATEMENT:  SELECT 1/0

2025-03-02 18:19:19.327 CET [2246291]:  L=2a02:...:7591, h=2a02:...:4a7
ERROR:  division by zero
2025-03-02 18:19:19.327 CET [2246291]:  L=2a02:...:7591, h=2a02:...:4a7
STATEMENT:  SELECT 1/0

Best, Jim

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2025-03-02 18:35:35 Re: Add Postgres module info
Previous Message Srinath Reddy 2025-03-02 17:54:01 Re: making EXPLAIN extensible