pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17538: Dynamically updating log_hostname not affect the disconnection log
2+ messages / 2 participants
[nested] [flat]

* BUG #17538: Dynamically updating log_hostname not affect the disconnection log
@ 2022-07-03 11:14 PG Bug reporting form <noreply@postgresql.org>
  2022-07-04 17:23 ` Re: BUG #17538: Dynamically updating log_hostname not affect the disconnection log Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2022-07-03 11:14 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: teng_wang13@163.com

The following bug has been logged on the website:

Bug reference:      17538
Logged by:          Parachute Parachute
Email address:      teng_wang13@163.com
PostgreSQL version: 14.2
Operating system:   Ubuntu 18.04
Description:        

As per the manual,
log_hostname (boolean)
By default, connection log messages only show the IP address of the
connecting host. Turning this parameter on causes logging of the host name
as well. 

The parameter could be updated on the fly. However, dynamically updating
log_hostname did not affect the disconnection log. I start up Postgres
server with log_hostname set 'no', which means not logging of the host name
in connection log. Then I connected to Postgres with root 'wang' using:

> ./psql -U wang -h localhost -p 5432

In the logfile, connection log messages only show the IP address (127.0.0.1)
of the connecting host, rather than the host name (localhost).

Then, I update log_hostname to 'yes' in postgresql.conf, and send SIGHUP
signal to reload configuration files.

I saw the logs showing the parameter was updated:
2022-07-03 10:50:54.477 UTC [5955] LOG:  received SIGHUP, reloading
configuration files
2022-07-03 10:50:54.478 UTC [5955] LOG:  parameter "log_hostname" changed to
"yes"

After I disconnected to Postgres, connection log messages kept showing the
IP address (127.0.0.1), which expected to show the host name (localhost).
This means updating log_hostname did not take effect.



The full logfile:

2022-07-03 10:49:08.191 UTC [5955] LOG:  database system is ready to accept
connections
2022-07-03 10:50:08.905 UTC [5972] LOG:  connection received: host=127.0.0.1
port=37828
2022-07-03 10:50:08.905 UTC [5972] LOG:  connection authorized: user=wang
database=wang application_name=psql
2022-07-03 10:50:54.477 UTC [5955] LOG:  received SIGHUP, reloading
configuration files
2022-07-03 10:50:54.478 UTC [5955] LOG:  parameter "log_hostname" changed to
"yes"
2022-07-03 10:51:24.416 UTC [5972] LOG:  disconnection: session time:
0:01:15.510 user=wang database=wang host=127.0.0.1 port=37828



**Suggest to fix:
in src/backend/tcop/postgres.c
static void log_disconnections(int code, Datum arg),

update 'port->remote_host' based on log_hostname as the method
BackendInitialize(Port *port) does.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #17538: Dynamically updating log_hostname not affect the disconnection log
  2022-07-03 11:14 BUG #17538: Dynamically updating log_hostname not affect the disconnection log PG Bug reporting form <noreply@postgresql.org>
@ 2022-07-04 17:23 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2022-07-04 17:23 UTC (permalink / raw)
  To: teng_wang13@163.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> The parameter could be updated on the fly. However, dynamically updating
> log_hostname did not affect the disconnection log.

This is operating as designed: the host name is captured at connection
time, and the log_disconnection message just repeats it.  What you
propose would not be an improvement, because it'd make it impossible
to match up log_disconnections messages with log_connections ones.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-07-04 17:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-07-03 11:14 BUG #17538: Dynamically updating log_hostname not affect the disconnection log PG Bug reporting form <noreply@postgresql.org>
2022-07-04 17:23 ` Tom Lane <tgl@sss.pgh.pa.us>

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