Skip site navigation (1) Skip section navigation (2)

Re: TCP keepalive support for libpq

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Tollef Fog Heen <tollef(dot)fog(dot)heen(at)collabora(dot)co(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: TCP keepalive support for libpq
Date: 2010-02-09 14:34:10
Message-ID: (view raw or whole thread)
Lists: pgsql-hackers
Tollef Fog Heen wrote:
> (please Cc me on replies, I am not subscribed)
> Hi,
> libpq currently does not use TCP keepalives.  This is a problem in our
> case where we have some clients waiting for notifies and then the
> connection is dropped on the server side.  The client never gets the FIN
> and thinks the connection is up.  The attached patch unconditionally
> adds keepalives.  I chose unconditionally as this is what the server
> does.  We didn't need the ability to tune the timeouts, but that could
> be added with reasonable ease.

ISTM that the default behavior should be keep alives disabled, as it is 
now, and those wanting it can just set it in their apps:

setsockopt(PQsocket(conn), SOL_SOCKET, SO_KEEPALIVE, ...)

If you really want libpq to manage this, I think you need to expose the 
probe interval and timeouts.  There should be some platform checks as 
well.  Check out...

Andrew Chernow
eSilo, LLC
every bit counts

In response to


pgsql-hackers by date

Next:From: Magnus HaganderDate: 2010-02-09 14:36:55
Subject: Re: About psycopg2 (by its author)
Previous:From: Magnus HaganderDate: 2010-02-09 14:33:53
Subject: Re: buildfarm breakage

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group