Lists: | pgsql-hackers |
---|
From: | "Jaime Casanova" <jaime(at)2ndquadrant(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | keepalives_* parameters usefullness |
Date: | 2011-07-04 08:42:43 |
Message-ID: | 87wrfya130.fsf@casanova1.SEINGALT |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
AFAIU TFM if i set keepalives_* parameters in a conninfo they set the
internal counters to these values so if i execute:
"""
conn = PQconnectdb("host=192.168.204.10 keepalives=1 keepalives_idle=45 keepalives_interval=5 keepalives_count=5");
"""
that means that the client's connection to the server in 192.168.204.10
will wait 45 seconds after the last packet sent to the server and then
will sent a probe every 5 seconds, 5 times...
if all of the above is right then if in the client i execute a PQexec() when
the connection has already drop it should detect the failure after 1
minute 10 seconds. is that right or am i misunderstanding this?
the reason i ask is that when i use that exact conninfo it detects the
failure condition after 15 minutes always... well, actually it waits the
same time even if i doesn't set anything...
i even used getsockopt() to ensure TCP_KEEPIDLE was being setted and
tried to set it myself with setsockopt() with the same results.
BTW, this paper (http://es.scribd.com/doc/2586622/tcpkeepalivehowto) on
section "4.2. The setsockopt function call" page 9 says that to set
TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT we should use level SOL_TCP
but on src/interfaces/libpq/fe-connect.c we use IPPROTO_TCP instead.
any leads?
--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL
Soporte 24x7, desarrollo, capacitación y servicios
From: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
---|---|
To: | Jaime Casanova <jaime(at)2ndquadrant(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: keepalives_* parameters usefullness |
Date: | 2011-07-04 08:47:49 |
Message-ID: | CA+U5nMLeBKk10+1hA6ENjXBo-bEafgsA8EckhmYD6oGRPFer7g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Jul 4, 2011 at 9:42 AM, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
> i even used getsockopt() to ensure TCP_KEEPIDLE was being setted and
> tried to set it myself with setsockopt() with the same results.
There's a list of preconditions as to when these settings take effect,
otherwise they are a no-op.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From: | "Jaime Casanova" <jaime(at)2ndquadrant(dot)com> |
---|---|
To: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: keepalives_* parameters usefullness |
Date: | 2011-07-04 19:00:40 |
Message-ID: | 87sjqlj2g7.fsf@casanova1.SEINGALT |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> On Mon, Jul 4, 2011 at 9:42 AM, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
>
>> i even used getsockopt() to ensure TCP_KEEPIDLE was being setted and
>> tried to set it myself with setsockopt() with the same results.
>
> There's a list of preconditions as to when these settings take effect,
> otherwise they are a no-op.
>
do we know what those preconditions are? TFM just says:
"""
keepalives_idle
Controls the number of seconds of inactivity after which TCP should send
a keepalive message to the server. A value of zero uses the system
default. This parameter is ignored for connections made via a
Unix-domain socket, or if keepalives are disabled. It is only supported
on systems where the TCP_KEEPIDLE or TCP_KEEPALIVE socket option is
available, and on Windows; on other systems, it has no effect.
"""
which made me think that on my debian system it should work so maybe we
want to document those preconditions, even a statement indicating that
other factors can prevent this working as expected would be good
--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL
Soporte 24x7, desarrollo, capacitación y servicios
From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Jaime Casanova <jaime(at)2ndquadrant(dot)com> |
Cc: | Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: keepalives_* parameters usefullness |
Date: | 2011-07-05 02:14:48 |
Message-ID: | CAHGQGwF0wGd8C2xnOOrd1gGLof34YMU=h1EyDrfggYSH5jkzvw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Jul 5, 2011 at 4:00 AM, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
> Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
>> There's a list of preconditions as to when these settings take effect,
>> otherwise they are a no-op.
>>
>
> do we know what those preconditions are?
The keepalives don't work at least on linux when the connection is
terminated after sending a packet and before receiving TCP-level ACK.
Regards,
--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center