Re: [Bug / Question ] " authentication_timeout " is invalid.

Lists: pgsql-bugs
From: 林俊彥 <james(dot)lin(at)cenoq(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: [Bug / Question ] " authentication_timeout " is invalid.
Date: 2015-09-16 10:27:46
Message-ID: CAGRvhK0Kheup8TzVR0xan8ygqNO4i19++QeobowsxHr49DQLdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi, sir,

the "postgresql.conf" 's "authentication_timeout" is not active.

The Log:
-------------------------------------------------------------------------------------------------
[BEGIN] 2015/9/16 17:57:37
[postgres(at)pg95 ~]$ psql -V
psql (PostgreSQL) 9.5alpha2
[postgres(at)pg95 ~]$ time psql -c 'show authentication_timeout ;'
Password:
authentication_timeout
------------------------
1min
(1 row)
real 4m39.528s
user 0m0.003s
sys 0m0.002s

[END] 2015/9/16 18:03:10
---------------------------------------------------------------------------------------------------
The document is said :
From:

http://www.postgresql.org/docs/9.4/static/runtime-config-connection.html

authentication_timeout (integer)

Maximum time to complete client authentication, in seconds. If a would-be
client has not completed the authentication protocol in this much time, the
server closes the connection. This prevents hung clients from occupying a
connection indefinitely. The default is one minute (1m). This parameter can
only be set in the postgresql.conf file or on the server command line.

I can't find about this information or solution by goolge search or forum,
Please tell me how to verify it is active . or check it running?

Best Regards,

James Lin


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: 林俊彥 <james(dot)lin(at)cenoq(dot)com>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [Bug / Question ] " authentication_timeout " is invalid.
Date: 2015-09-16 15:52:51
Message-ID: CAMkU=1wxbupDiMWuEXN6Gw3L+MSgx7AfuPbouQCsDTgnK44Xhg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Wed, Sep 16, 2015 at 3:27 AM, 林俊彥 <james(dot)lin(at)cenoq(dot)com> wrote:

> Hi, sir,
>
> the "postgresql.conf" 's "authentication_timeout" is not active.
>
> The Log:
>
> -------------------------------------------------------------------------------------------------
> [BEGIN] 2015/9/16 17:57:37
> [postgres(at)pg95 ~]$ psql -V
> psql (PostgreSQL) 9.5alpha2
> [postgres(at)pg95 ~]$ time psql -c 'show authentication_timeout ;'
> Password:
> authentication_timeout
> ------------------------
> 1min
> (1 row)
> real 4m39.528s
> user 0m0.003s
> sys 0m0.002s
>
> [END] 2015/9/16 18:03:10
>
> ---------------------------------------------------------------------------------------------------
> The document is said :
> From:
>
> http://www.postgresql.org/docs/9.4/static/runtime-config-connection.html
>
> authentication_timeout (integer)
>
> Maximum time to complete client authentication, in seconds. If a would-be
> client has not completed the authentication protocol in this much time, the
> server closes the connection. This prevents hung clients from occupying a
> connection indefinitely. The default is one minute (1m). This parameter
> can only be set in the postgresql.conf file or on the server command line.
>
> I can't find about this information or solution by goolge search or forum,
> Please tell me how to verify it is active . or check it running?
>

What happens behind the scenes is that psql first tries to connect without
a password. It is told that it can't connect without a password. It
closes the uncompleted connection. Then psql asks you for a password,
waits until you enter one, and then starts a new connection using the
password. So during the wait time, there is no pending connection to the
database to be timed out. It is the client program psql which is doing the
waiting, not the database server.

Cheers,

Jeff


From: 林俊彥 <james(dot)lin(at)cenoq(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [Bug / Question ] " authentication_timeout " is invalid.
Date: 2015-09-17 04:02:02
Message-ID: CAGRvhK2a+8bcY7pAZy47Ke=Tn99Vhgw1GJ=pEWgojEroqiLa4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi , Jeff,
Thank you for reply. I used to use in the following ways but still
could not be verified:
----------- Log start ---------------------
[BEGIN] 2015/9/17 11:51:51
[postgres(at)pg95 ~]$ cat test.sh

#!/bin/bash
ip a |grep eth0
psql -h 100.200.100.211<<EOF
show authentication_timeout;
select now();
\! sh net_test.sh
select now();
EOF

[postgres(at)pg95 ~]$ cat net_test.sh

#!/bin/bash
sudo ifdown eth0
sleep 90
sudo ifup eth0

[postgres(at)pg95 ~]$ ./test.sh
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfif
o_fast state UP qlen 1000
inet 100.200.100.211/8 brd 100.255.255.255 scope global eth0
authentication_timeout
------------------------
1min
(1 row)
now
-------------------------------
2015-09-17 11:52:43.842508+08
(1 row)
now
-------------------------------
2015-09-17 11:54:18.161079+08
(1 row)

[END] 2015/9/17 11:54:35

----------- Log end ----------------------

Could you give me an example to verify it? Let me verify it is active or
not. thank you !!

best regards,

James

2015-09-16 23:52 GMT+08:00 Jeff Janes <jeff(dot)janes(at)gmail(dot)com>:

> On Wed, Sep 16, 2015 at 3:27 AM, 林俊彥 <james(dot)lin(at)cenoq(dot)com> wrote:
>
>> Hi, sir,
>>
>> the "postgresql.conf" 's "authentication_timeout" is not active.
>>
>> The Log:
>>
>> -------------------------------------------------------------------------------------------------
>> [BEGIN] 2015/9/16 17:57:37
>> [postgres(at)pg95 ~]$ psql -V
>> psql (PostgreSQL) 9.5alpha2
>> [postgres(at)pg95 ~]$ time psql -c 'show authentication_timeout ;'
>> Password:
>> authentication_timeout
>> ------------------------
>> 1min
>> (1 row)
>> real 4m39.528s
>> user 0m0.003s
>> sys 0m0.002s
>>
>> [END] 2015/9/16 18:03:10
>>
>> ---------------------------------------------------------------------------------------------------
>> The document is said :
>> From:
>>
>> http://www.postgresql.org/docs/9.4/static/runtime-config-connection.html
>>
>> authentication_timeout (integer)
>>
>> Maximum time to complete client authentication, in seconds. If a would-be
>> client has not completed the authentication protocol in this much time, the
>> server closes the connection. This prevents hung clients from occupying a
>> connection indefinitely. The default is one minute (1m). This parameter
>> can only be set in the postgresql.conf file or on the server command
>> line.
>>
>> I can't find about this information or solution by goolge search or forum,
>> Please tell me how to verify it is active . or check it running?
>>
>
> What happens behind the scenes is that psql first tries to connect without
> a password. It is told that it can't connect without a password. It
> closes the uncompleted connection. Then psql asks you for a password,
> waits until you enter one, and then starts a new connection using the
> password. So during the wait time, there is no pending connection to the
> database to be timed out. It is the client program psql which is doing the
> waiting, not the database server.
>
> Cheers,
>
> Jeff
>


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: 林俊彥 <james(dot)lin(at)cenoq(dot)com>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [Bug / Question ] " authentication_timeout " is invalid.
Date: 2015-09-17 17:03:40
Message-ID: CAMkU=1yNZMPu+aqRSiMpaZqUxgo8NWkjyo6u9kX2pDkYEPpewA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Wed, Sep 16, 2015 at 9:02 PM, 林俊彥 <james(dot)lin(at)cenoq(dot)com> wrote:

> Hi , Jeff,
> Thank you for reply. I used to use in the following ways but still
> could not be verified:
> ----------- Log start ---------------------
> [BEGIN] 2015/9/17 11:51:51
> [postgres(at)pg95 ~]$ cat test.sh
>
> #!/bin/bash
> ip a |grep eth0
> psql -h 100.200.100.211<<EOF
> show authentication_timeout;
> select now();
> \! sh net_test.sh
> select now();
> EOF
>

That isn't going to work because net_test.sh isn't called until after the
connection is authenticated.

It is difficult to interrupt the process during the brief instant between
when the connection was opened and when it is authenticated.

Start psql, and when it is waiting for the password, find the pid for psql
and start gdb against the psql process (gdb -p <pid>)

In gdb, do:

(gdb) b PQconnectStartParams
Breakpoint 1 at 0x7f5de60bdf70: file fe-connect.c, line 561.
(gdb) c

Then go back and complete the password in psql. The gdb session will have
triggered the breakpoint.

Wait for less than the timeout, and hit 'c' and enter in the debugger. The
connection will complete.

Or, wait for more than the timeout and hit 'c' and enter in the debugger.
The connection will error out, as the server side hung up on it.

Cheers,

Jeff


From: 林俊彥 <james(dot)lin(at)cenoq(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [Bug / Question ] " authentication_timeout " is invalid.
Date: 2015-09-18 01:34:55
Message-ID: CAGRvhK2if8tECVyTqtZ752Zy1pwm+BiOYT2_UhusC5n+Lpg31w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Thank you for all your assistance.

Best Regard,
James

2015-09-18 1:03 GMT+08:00 Jeff Janes <jeff(dot)janes(at)gmail(dot)com>:

> On Wed, Sep 16, 2015 at 9:02 PM, 林俊彥 <james(dot)lin(at)cenoq(dot)com> wrote:
>
>> Hi , Jeff,
>> Thank you for reply. I used to use in the following ways but still
>> could not be verified:
>> ----------- Log start ---------------------
>> [BEGIN] 2015/9/17 11:51:51
>> [postgres(at)pg95 ~]$ cat test.sh
>>
>> #!/bin/bash
>> ip a |grep eth0
>> psql -h 100.200.100.211<<EOF
>> show authentication_timeout;
>> select now();
>> \! sh net_test.sh
>> select now();
>> EOF
>>
>
>
> That isn't going to work because net_test.sh isn't called until after the
> connection is authenticated.
>
> It is difficult to interrupt the process during the brief instant between
> when the connection was opened and when it is authenticated.
>
> Start psql, and when it is waiting for the password, find the pid for psql
> and start gdb against the psql process (gdb -p <pid>)
>
> In gdb, do:
>
> (gdb) b PQconnectStartParams
> Breakpoint 1 at 0x7f5de60bdf70: file fe-connect.c, line 561.
> (gdb) c
>
> Then go back and complete the password in psql. The gdb session will have
> triggered the breakpoint.
>
> Wait for less than the timeout, and hit 'c' and enter in the debugger.
> The connection will complete.
>
> Or, wait for more than the timeout and hit 'c' and enter in the debugger.
> The connection will error out, as the server side hung up on it.
>
> Cheers,
>
> Jeff
>