Re: Logging which local address was connected to in log_line_prefix

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, 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-04-06 22:01:01
Message-ID: 3101493.1743976861@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Sabino Mullane <htamfids(at)gmail(dot)com> writes:
> I have not attempted the caching change yet.

After some thought I concluded that caching the local-address string
in MyProcPort itself would be the most robust way of making that work.
Otherwise you need some way to update the cache when MyProcPort is
created (in case the process already emitted some messages before
that), and the patch starts to spread into other places.

I think 0004 attached is about committable, but there is one
definitional point that is troubling me slightly: our choice to
emit "[none]" when there's no port isn't consistent with the
log_line_prefix documentation's statement that

... Some escapes are only recognized by session processes,
and will be treated as empty by background processes such as
the main server process.

Since we've marked %L as "Session only" = yes, this implies
that it should print as an empty string not "[none]".
We could either

1. Ignore the inconsistency, commit 0004 as-is.

2. Change the output to be an empty string in background processes.
This is consistent, but it goes against our upthread feeling
that "[none]" would avoid confusion.

3. Mark %L as "Session only" = no. This seems a little weird,
but it'd also be consistent.

4. Add something to the above-quoted text about %L being an exception.

I don't really care for #3 or #4, but I'm ambivalent between #1 and
#2. I think the worry about confusion originated when the patch
would print "[local]" for either a Unix socket or a background
process, and that certainly was confusing. "[local]" versus
an empty string is not so ambiguous, so maybe it's fine.

Thoughts?

regards, tom lane

Attachment Content-Type Size
0004-Add-local-address-to-log_line_prefix.patch text/x-diff 3.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-04-06 22:41:18 Re: Logging which local address was connected to in log_line_prefix
Previous Message Daniel Gustafsson 2025-04-06 21:52:34 Re: Possibly hard-to-read message