Re: user connection not recorded? - Mailing list pgsql-general

From Adrian Klaver
Subject Re: user connection not recorded?
Date
Msg-id 55BA3009.9030808@aklaver.com
Whole thread Raw
In response to user connection not recorded?  (Melvin Davidson <melvin6925@gmail.com>)
Responses Re: user connection not recorded?  (Melvin Davidson <melvin6925@gmail.com>)
Re: user connection not recorded?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 07/30/2015 06:42 AM, Melvin Davidson wrote:
> I have a puzzling question.
>
> All through the error log, there are connections for [unknown] user.
> EG:
> 2015-07-30 00:00:00 CDT [6577]: [1-1]: : [unknown]: LOG:  connection
> received: host=173.239.101.98 port=50687
>
> The log_line_prefix   is  %t [%p]: [%l-1]: %h: %u:
>
> I can understand that the host is not available in nslookup, but why is
> the user not being recorded?

A quick look at the source shows that Postgres system process can have NULL username:

postinit.c:

 else if (IsBackgroundWorker)
        {
                if (username == NULL)
                {
                        InitializeSessionUserIdStandalone();
                        am_superuser = true;

which is then turned into 'unknown'

elog.c:

case 'u':
    if (MyProcPort)
        {
          const char *username = MyProcPort->user_name;

          if (username == NULL || *username == '\0')
                 username = _("[unknown]");


>
> *Melvin Davidson*


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Renato Oliveira
Date:
Subject: Re: [ADMIN] How Many PG_Locks are considered too many
Next
From: Melvin Davidson
Date:
Subject: Re: user connection not recorded?