[sr-dev] mysql_ping in db_mysql_submit_query
Daniel-Constantin Mierla
miconda at gmail.com
Fri Sep 6 08:59:25 CEST 2019
I would suggest to add a new module parameter to control it, it is
better than a compile time flag.
Being code that tries to resolve a bug/issue, it can still be pushed to
master branch even it is testing phase, and if proves to be useless can
be reverted later.
Cheers,
Daniel
On 06.09.19 08:46, Juha Heinanen wrote:
> As was found out in "Kamailio stops processing requests over UDP"
> thread, db_mysql_submit_query() in some circumstances hangs when it
> executes mysql_ping here:
>
> if (my_ping_interval) {
> t = time(0);
> if ((t - CON_TIMESTAMP(_h)) > my_ping_interval) {
> for (i=0; i < (db_mysql_auto_reconnect ? 3 : 1); i++) {
> if (mysql_ping(CON_CONNECTION(_h))) {
> LM_INFO("driver error on ping: %s\n", mysql_error(CON_CONNECTION(_h)));
> counter_inc(mysql_cnts_h.driver_err);
> } else {
> break;
> }
> }
> }
> ...
> }
>
> Comment in front of db_mysql_submit_query() function tells:
>
> * Send a SQL query to the database server. This methods tries to reconnect
> * to the server if the connection is gone and the auto_reconnect parameter is
> * enabled. It also issues a mysql_ping before the query to connect again after
> * a long waiting period because for some older mysql versions the auto reconnect
> * don't work sufficient. If auto_reconnect is enabled and the server supports it,
> * then the mysql_ping is probably not necessary, but its safer to do it in this
> * cases too.
> *
>
> The text was most likely written many years ago and auto reconnect now
> works OK in mysql versions in use today.
>
> I would like to test if the hangup could be prevented without the above
> code. Would it be possible to make the code optional via a compilation
> flag or by some other means?
>
> -- Juha
>
> _______________________________________________
> Kamailio (SER) - Development Mailing List
> sr-dev at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
More information about the sr-dev
mailing list