<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Alex,<br>
    Could you supply me a bit more information about your setup?<br>
    <br>
    And for anyone with a bit more knowledge of the db_postgres module:<br>
    <br>
    I've been testing a lot now and really have an issue with the
    receiving an incorrect resultset.<br>
    I think I finally have found what's really going wrong.<br>
    <br>
    The permissions module forks into several threads, and then every
    thread is requesting "select table_version from version where
    table_name='trusted'".<br>
    But all threads do this on the same database connection.<br>
    And I see that sometimes thread A sends the query, then thread B
    sends the query, on the same database connection.<br>
    Then thread B is reading the the resultset, and then thread A is
    reading the resultset.<br>
    So it is possible that thread A receives the resultset, which is
    actually the answer of the query of thread B.<br>
    <br>
    When all threads are requesting the same query (select table_version
    from version where table_name='trusted') that's not a big issue,<br>
    but when at the same time I receive a SIP REGISTER, Another query is
    sent on the same database connection as the query from the
    permissions module.<br>
    Then the results are swapped, and the table_version function will
    stop kamailio.<br>
    <br>
    Shouldn't there be some kind locking mechanisch, that the thread
    that's sending a query to the database server, through a database
    connection, will also be the thread that's receiving the first
    resultset. It appears that such kind of locking is not in use at the
    moment.<br>
    <br>
    With kind regards,<br>
    Robert Verspuy<br>
    <br>
    <br>
    On 10/12/2010 05:01 PM, Alex Balashov wrote:
    <blockquote
      cite="mid:C49EA370-28AB-4766-A282-2E91B8C52FC7@evaristesys.com"
      type="cite">
      <div>Robert,</div>
      <div><br>
      </div>
      <div>We use Postgres 8.4 as well with the permissions module, but
        have not had this problem...<br>
        <br>
        <div>--</div>
        <div>Alex Balashov - Principal</div>
        <div>Evariste Systems LLC</div>
        <div>1170 Peachtree Street</div>
        <div>12th Floor, Suite 1200</div>
        <div>Atlanta, GA 30309</div>
        <div>Tel: +1-678-954-0670</div>
        <div>Fax: +1-404-961-1892</div>
        <div>Web: <a moz-do-not-send="true"
            href="http://www.evaristesys.com/">http://www.evaristesys.com/</a></div>
      </div>
      <div><br>
        On Oct 12, 2010, at 10:30 AM, Robert Verspuy &lt;<a
          moz-do-not-send="true" href="mailto:robert@exa-omicron.nl">robert@exa-omicron.nl</a>&gt;
        wrote:<br>
        <br>
      </div>
      <blockquote type="cite">
        <div> I've got a strange issue with the latest kamailio. I also
          had this problem with kamailio 3.0.3 downloaded from the
          webpage.<br>
          <br>
          I can start kamailio, but after a while (sometimes within one
          minuten, sometimes after an hour),<br>
          I get the following log errors:<br>
          <br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26621]: ERROR:
          &lt;core&gt; [db.c:387]: invalid type (3) or nul (0) version
          columns for trusted<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26621]: ERROR:
          &lt;core&gt; [db.c:405]: querying version for table trusted<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26621]: ERROR: permissions
          [trusted.c:249]: error during table version check.<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26621]: ERROR:
          &lt;core&gt; [sr_module.c:832]: init_mod_child(): Error while
          initializing module permissions
          (//lib/kamailio/modules_k/permissions.so)<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26621]: ERROR:
          &lt;core&gt; [pt.c:481]: ERROR: fork_tcp_process(): init_child
          failed for process 10, pid 26621, "tcp receiver child=0"<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26621]: ERROR:
          &lt;core&gt; [tcp_main.c:4811]: ERROR: tcp_main: fork failed:
          Success<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26625]: : &lt;core&gt;
          [pass_fd.c:103]: ERROR: recv_all: 1st recv on 21 failed:
          Connection reset by peer<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26625]: : &lt;core&gt;
          [tcp_main.c:3323]: ERROR: handle_tcp_child: read from tcp
          child 0  (pid 26621, no 10) Connection reset by peer [104]<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26625]: : &lt;core&gt;
          [pass_fd.c:293]: ERROR: receive_fd: EOF on 19<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26611]: ALERT:
          &lt;core&gt; [main.c:738]: child process 26621 exited
          normally, status=255<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26611]: INFO: &lt;core&gt;
          [main.c:756]: INFO: terminating due to SIGCHLD<br>
          Oct 12 15:46:24 sp01 /sbin/kamailio[26625]: INFO: &lt;core&gt;
          [main.c:807]: INFO: signal 15 received<br>
          <br>
          Looking at the error message, it thinks that the column type
          of table_version in the table version is a string (type 3),
          and it should be an int (type 1).<br>
          But in the database it really is an int.<br>
          <br>
          When I run kamailio with debugging on level 5, I see that it's
          trying to run the "select table_version from version where
          table_name='trusted'" several times when kamailio starts (for
          every child thread).<br>
          And then minutes, of even an hour later, it suddenly continues
          with that check, but based on a database response from another
          query.<br>
          This is the "select password from subscriber ....etc...".<br>
          And that column is indeed an string.<br>
          <br>
          I'm using PostgreSQL 8.4 as server,<br>
          but maybe someone has seen this before, or now where I have to
          start looking?<br>
          I first saw it yesterday when started to use the permissions
          module.<br>
          I only see this with the trusted table,<br>
          And always it uses the "select password from subscriber ... "
          response when giving this error.<br>
          <br>
          So is this an error in the permissions module / trusted.c
          file?<br>
          or something in auth_db that's not freeing the response
          correctly?<br>
          <br>
          Strange thing is, that is sometimes happens very quick, and
          sometimes it can take an half hour or hour.<br>
          <br>
          I can mail the full log if anybody is interested and thinks
          he/she can help me.<br>
          <br>
          With kind regards,<br>
          Robert Verspuy<br>
          <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" href="http://www.exa-omicron.nl">http://www.exa-omicron.nl</a></div>
        </div>
      </blockquote>
      <blockquote type="cite">
        <div><span>_______________________________________________</span><br>
          <span>sr-dev mailing list</span><br>
          <span><a moz-do-not-send="true"
              href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a></span><br>
          <span><a moz-do-not-send="true"
              href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a></span><br>
        </div>
      </blockquote>
    </blockquote>
    <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 class="moz-txt-link-freetext" href="http://www.exa-omicron.nl">http://www.exa-omicron.nl</a></div>
  </body>
</html>