[sr-dev] DB API and connection keepalive

Jason Penton jason.penton at smilecoms.com
Tue Sep 22 12:55:19 CEST 2009


Hey Henning,


On Tue, Sep 22, 2009 at 12:46 PM, Henning Westerholt <
henning.westerholt at 1und1.de> wrote:

> On Dienstag, 22. September 2009, Jason Penton wrote:
> > Hi Andrei,
> >
> > From what I have seen in the code this is pretty useless (no offence).
> >
> > The ping in this particular instance is only executed JUST before a real
> > query is to be issued. i.e. if a query is not used in Kamailio for a
> couple
> > of hours - the ping is actually never sent...........
>
>
> Hi Jason,
>
>
> you're right that its not executed with a timer or similar, but the
> mysql_ping() should reconnect to the database if the auto reconnect is
> activated, according the documentation:
>
>
> http://dev.mysql.com/doc/refman/5.0/en/mysql-ping.html
>

Actually the reconnect doesnt work if your firewall has torn down the
connection. You can try this with other mysql clients like - the usual
client, toad, etc. Leave your connection idle for about 45 mins and you will
see that there's nothing you can do to reconnect.

I have tested this extensively and can only imageine that because the
firewall has closed the connection, the reconnect in mysql doesnt work -
because the socket has been torn down underneath mysql (at the OS level). So
effectively you see a hangin process in Kamailio up to 5 minutes :) which is
REALLLLLLLLY bad :D

Ok so I am going to go ahead with using a timer to ping the mysql cons in
the db_pool. Everyone happy with that?

Cheers
Jason

>
>
> > what I have noticed is that when the connection is torn down by the
> > firewall, the ping actually hangs (reconnect fails), etc
> >
> > So, we NEED a proper ping (keepalive) functionality :D
>
>
> This could be implemented with help of the internal timers, just execute
> periodically the mysql_ping command, for example.
>
>
> Henning
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20090922/8e3b0057/attachment-0003.htm>


More information about the sr-dev mailing list