Re: Keep-alive support - Mailing list pgsql-interfaces

From Leandro Lucarella
Subject Re: Keep-alive support
Date
Msg-id 45704DD6.1040201@integratech.com.ar
Whole thread Raw
In response to Re: Keep-alive support  (Leandro Lucarella <llucarella@integratech.com.ar>)
List pgsql-interfaces
For pgsql-hackers, here is the original thread (I think this mail is 
appropriate for this list, correct me if I'm wrong):
http://archives.postgresql.org/pgsql-interfaces/2006-11/msg00014.php

Leandro Lucarella escribió:
> Thanks all for your responses, but this is *not* a libpqxx issue, just 
> because I'm doing the test using plain libpq. Anyways, I have a little 
> more information about my problem and it's no libpq either =)
> 
> The problem is shown when the time between the wire is unplugged and the 
> use of the connection is not long enough to let the keep-alive kill the 
> connection. Then the connection becomes active and the TCP timers looks 
> like go back to the defaults, because there is data in the socket queue 
> to send. So it's an OS/TCP issue.
> 
> I don't see any way to control this without using an application-level 
> keep-alive, so I appreciate any ideas and suggestions =)

Hi! It's me again =)

I was thinking about solutions for my problem, and I've come up with 
(mainly) this 3 ideas:

1) Add TIPC[1] support to Postgresql. This is the cleaner solution, I 
think, but the the hardest and could take a lot of time, but if I use 
some of the other hacks in the meantime and if there is interest on 
adding this to Postgresql officially, I can evaluate working on this 
seriously. What I'm sure I don't want is to keep my own Postresql fork.
So, what do you think about this? Or where should I ask?

2) Use a "monitor" dummy connection to postgres, do the TCP keep-alive 
tunning and select() the socket waiting for a disconnection. Since this 
socket will never be active (is that right? Or Postgresql sends any kind 
of control information on an idle connection?), the TCP keep-alive will 
be enough to determine if the connection is lost in a short period of 
time. If there is no problem with this, I think it could be a quick and 
not-so-nasty solution =)

3) Use Heartbeat[2] or make some other specific solution like it 
(probably using TIPC too). I don't like it at all, since I'm looking for 
a more self-contained solution, but it's another option.

I really appreciate any thought on this, and any suggestions.

TIA.

[1] http://tipc.sourceforge.net/
[2] http://www.linux-ha.org/HeartbeatProgram

-- 
Leandro Lucarella
Integratech S.A.
4571-5252


pgsql-interfaces by date:

Previous
From: Leandro Lucarella
Date:
Subject: Re: Keep-alive support
Next
From: "Kevin Fallis"
Date:
Subject: FW: query optimization on prepared statement through connection vi libpq