<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hello,<br>
    <br>
    I missed this patch, due to some traveling. It is good in my
    opinion, but a different purpose.<br>
    <br>
    Kamailio processes should not share a database connection as well.
    Storing the pid inside db connection structure is good to discover
    that some module does a fault DB initialization. Your investigation
    really helps a lot, thanks!<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <br>
    On 10/21/10 5:53 PM, Robert Verspuy wrote:
    <blockquote cite="mid:4CC06205.1040509@exa-omicron.nl" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      I found the cause of my issue.<br>
      <br>
      In the source lib/srdb1/* some kind of pooling is used.<br>
      When kamailio needs a database connection, the cmp_db_id function
      checks to see if there is already a database connection with the
      exact same params (username, database, server etc..).<br>
      <br>
      According to the PQ library every proces / thread should have it's
      own database connection.<br>
      The db_postgres is setup to use asynchronous I/O with the PQ
      library.<br>
      So when two threads are using the same database connection it is
      possible that,<br>
      the resultset from a query of thread A is returned to thread B.<br>
      The cmp_db_id function in lib/srdb1/db_id.c does _not_ check the
      PID.<br>
      <br>
      I've created a small patch to fix the problems mentioned above.<br>
      <br>
      The changes are made in lib/srdb1/* files<br>
      So if you apply them, it will be active for _every_ database
      module.<br>
      Maybe it's not needed for the mysql database,<br>
      but I *assume* it will not break when used on a mysql database.
      (not tested)<br>
      Maybe you will get a bit more database connections, but that
      depends on which modules you're using.<br>
      <br>
      What did I do:<br>
      <ul>
        <li>Added pid to the db_id struct.</li>
        <li>During initialization the pid is saved into the db_id
          struct.</li>
        <li>In cmp_db_id the pid is also checked when searching for a
          database connection to be reused.</li>
      </ul>
      With kind Regards,<br>
      Robert Verspuy<br>
      <br>
      <div class="moz-signature">-- <br>
        <b>Exa-Omicron</b><br>
        Patroonsweg 10<br>
        3892 DB Zeewolde<br>
        Tel.: 088-OMICRON (66 427 66)<br>
        <a moz-do-not-send="true" class="moz-txt-link-freetext"
          href="http://www.exa-omicron.nl">http://www.exa-omicron.nl</a></div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
  </body>
</html>