<p>Ok, so I believe I may have found the issue, or rather I think I know what's happening, just not where it all goes wrong.</p>

<p>In my kamailio config I have logic for some users to call through a list of numbers to find a number where they are able to take the call, pretty much like a hunt-group, trying the numbers one by one.</p>

<p>When none of the numbers are answered and one of these calls time out and Request Timeout occurs, it looks like the <code>timer</code> process would like to write a row for each call leg/branch to the <code>missed_calls</code> table and here's where the issue seems to occur (I've added some debug output to be able to trace back what's happening and 54110017 below is the mysql thread ID):</p>

<pre><code>Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: WARNING: db_mysql [km_dbase.c:80]: db_mysql_submit_query(): 54110017 entering db_mysql_submit_query
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: WARNING: db_mysql [km_dbase.c:89]: db_mysql_submit_query(): 54110017 mysql ping done
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: WARNING: db_mysql [km_dbase.c:101]: db_mysql_submit_query(): 54110017 submit_query(): insert into `missed_calls` (branch 1 data)
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: WARNING: db_mysql [km_dbase.c:116]: db_mysql_submit_query(): 54110017 db_mysql_submit_query returned 0
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: WARNING: db_mysql [km_dbase.c:80]: db_mysql_submit_query(): 54110017 entering db_mysql_submit_query
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: WARNING: db_mysql [km_dbase.c:101]: db_mysql_submit_query(): 54110017 submit_query(): insert into `missed_calls` (branch 2 data)
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: ERROR: db_mysql [km_dbase.c:128]: db_mysql_submit_query(): 54110017 driver error on query: SSL connection error: socket layer receive error (2026)
Feb 16 21:05:24 host /usr/sbin/kamailio[2731]: ERROR: <core> [db_query.c:235]: db_do_insert_cmd(): error while submitting query
</code></pre>

<p>I'm guessing that the two db_mysql_submit_query() calls run at almost the same time and that the first insert has not completed before the second insert wants to run, at which point something similar to what's described here occurs: <a href="http://dev.mysql.com/doc/refman/5.6/en/c-api-multiple-queries.html">http://dev.mysql.com/doc/refman/5.6/en/c-api-multiple-queries.html</a></p>

<p>This is only observed when the connection is running over SSL, so there's probably something related there.</p>

<p>OR.. my config is screwed up and I'm not working with branches in the correct way :)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/406#issuecomment-184863893">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZZIWFdsfBoScrtZp6Cq7myvcCDPkks5pk35igaJpZM4Gmb_R.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/406#issuecomment-184863893"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>