Re: [doc fix] PG10: wroing description on connect_timeout when multiple hosts are specified

From: Noah Misch <noah(at)leadboat(dot)com>
To: "Robert Haas (robertmhaas(at)gmail(dot)com)" <robertmhaas(at)gmail(dot)com>
Cc: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [doc fix] PG10: wroing description on connect_timeout when multiple hosts are specified
Date: 2017-05-15 03:45:11
Message-ID: 20170515034511.GP843225@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 12, 2017 at 08:54:13AM +0000, Tsunakawa, Takayuki wrote:
> From: pgsql-hackers-owner(at)postgresql(dot)org
> > [mailto:pgsql-hackers-owner(at)postgresql(dot)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 is down, libpq might wait for about 2 hours (depending on the OS's TCP keepalive setting), during which it tims out after connect_timeout and does not attempt to connect to other hosts.
>
> I'll add this item in the PostgreSQL 10 Open Items.

[Action required within three days. This is a generic notification.]

The above-described topic is currently a PostgreSQL 10 open item. Robert,
since you committed the patch believed to have created it, you own this open
item. If some other commit is more relevant or if this does not belong as a
v10 open item, please let us know. Otherwise, please observe the policy on
open item ownership[1] and send a status update within three calendar days of
this message. Include a date for your subsequent status update. Testers may
discover new open items at any time, and I want to plan to get them all fixed
well in advance of shipping v10. Consequently, I will appreciate your efforts
toward speedy resolution. Thanks.

[1] https://www.postgresql.org/message-id/20170404140717.GA2675809%40tornado.leadboat.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2017-05-15 03:50:36 Re: Concurrent ALTER SEQUENCE RESTART Regression
Previous Message Masahiko Sawada 2017-05-15 03:42:14 Fix a typo in reorderbuffer.c