[HACKERS] Re: [doc fix] PG10: wroing description on connect_timeout whenmultiple hosts are specified - Mailing list pgsql-hackers

From Tsunakawa, Takayuki
Subject [HACKERS] Re: [doc fix] PG10: wroing description on connect_timeout whenmultiple hosts are specified
Date
Msg-id 0A3221C70F24FB45833433255569204D1F6F5924@G01JPEXMBYT05
Whole thread Raw
In response to [HACKERS] [doc fix] PG10: wroing description on connect_timeout when multiplehosts are specified  ("Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>)
Responses [HACKERS] Re: [doc fix] PG10: wroing description on connect_timeout whenmultiple hosts are specified  ("Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>)
[HACKERS] Re: [doc fix] PG10: wroing description on connect_timeout whenmultiple hosts are specified  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Tsunakawa,
> Takayuki
> I found a wrong sentence here in the doc.  I'm sorry, this is what I asked
> you to add...
> 
> https://www.postgresql.org/docs/devel/static/libpq-connect.html#libpq-
> paramkeywords
> 
> connect_timeout
> Maximum wait for connection, in seconds (write as a decimal integer string).
> Zero or not specified means wait indefinitely. It is not recommended to
> use a timeout of less than 2 seconds. This timeout applies separately to
> each connection attempt. For example, if you specify two hosts and both
> of them are unreachable, and connect_timeout is 5, the total time spent
> waiting for a connection might be up to 10 seconds.
> 
> 
> The program behavior is that libpq times out after connect_timeout seconds
> regardless of how many hosts are specified.  I confirmed it like this:
> 
> $ export PGOPTIONS="-c post_auth_delay=30"
> $ psql -d "dbname=postgres connect_timeout=5" -h localhost,localhost -p
> 5432,5433
> (psql erros out after 5 seconds)
> 
> Could you fix the doc with something like this?
> 
> "This timeout applies across all the connection attempts. For example, if
> you specify two hosts and both of them are unreachable, and connect_timeout
> is 5, the total time spent waiting for a connection is up to 5 seconds."
> 
> Should we also change the minimum "2 seconds" part to be longer, according
> to the number of hosts?

Instead, I think we should fix the program to match the documented behavior.  Otherwise, if the first database machine
isdown, libpq might wait for about 2 hours (depending on the OS's TCP keepalive setting), during which it tims out
afterconnect_timeout and does not attempt to connect to other hosts.
 

I'll add this item in the PostgreSQL 10 Open Items.

Regards
Takayuki Tsunakawa




pgsql-hackers by date:

Previous
From: "Tsunakawa, Takayuki"
Date:
Subject: Re: [HACKERS] [bug fix] PG10: libpq doesn't connect to alternativehosts when some errors occur
Next
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] snapbuild woes