Ok, so I tested your code in a production system and just replacing the module 
didn't always seem to do the trick, I still ended up with messages like these:
```
Nov 25 15:35:26 /usr/sbin/kamailio[15053]: ERROR: db_mysql [km_dbase.c:128]: 
db_mysql_submit_query(): driver error on query: SSL connection error: socket 
layer receive error (2026)
Nov 25 15:35:26 /usr/sbin/kamailio[15053]: ERROR: <core> [db_query.c:235]: 
db_do_insert_cmd(): error while submitting query
```

The error above lead me to the conclusion that "mysql_ping()" wasn't performed 
on these requests. Dug into the MySQL C API and from what I understand the 
MYSQL_OPT_RECONNECT=true is only used by and acted upon by mysql_ping(), no 
query functions. So I decreased the "ping_interval" setting to:
```
modparam("db_mysql", "ping_interval", 5);
```
to force mysql_ping to run more frequently. This code has now been running for 
almost 24h on a production system and it looks promising. Made a small addition 
to your code to get a warning if connection ID changed after mysql_ping (see 
attached diff). Now I'm getting a few of these messages:
```
Nov 26 08:55:27 /usr/sbin/kamailio[29363]: WARNING: db_mysql [km_dbase.c:91]: 
db_mysql_submit_query(): mysql thread id changed due to reconnect in mysql_ping
```
but from what I can see no more failed INSERTs.

I'm thinking MYSQL_OPT_RECONNECT together with frequent mysql_ping()'s seems to 
have done the trick.

[mysql_ping.diff.txt](https://github.com/kamailio/kamailio/files/44746/mysql_ping.diff.txt)



---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/406#issuecomment-159849980
_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to