keepalives_* parameters usefullness
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
On Mon, Jul 4, 2011 at 9:42 AM, Jaime Casanova <jaime@2ndquadrant.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
Simon Riggs <simon@2ndQuadrant.com> writes:
On Mon, Jul 4, 2011 at 9:42 AM, Jaime Casanova <jaime@2ndquadrant.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
On Tue, Jul 5, 2011 at 4:00 AM, Jaime Casanova <jaime@2ndquadrant.com> wrote:
Simon Riggs <simon@2ndQuadrant.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