<!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>
    what version of postgres and postgres client library are you using?<br>
    <br>
    According to the docs from devel manual, this is the function that
    should be used to reconnect:<br>
    <br>
    <dt><code>PQreset</code>
    </dt>
    <dd>
      Resets the communication channel to the server.
      <pre class="example">void PQreset(PGconn *conn);
</pre>
      This function will close the connection
      to the server and attempt to reestablish a new
      connection to the same server, using all the same
      parameters previously used. This may be useful for
      error recovery if a working connection is lost.</dd>
    <br>
    <br>
    You may see more here:<br>
<a class="moz-txt-link-freetext" href="http://www.network-theory.co.uk/docs/postgresql/vol2/DatabaseConnectionControlFunctions.html">http://www.network-theory.co.uk/docs/postgresql/vol2/DatabaseConnectionControlFunctions.html</a><br>
    <br>
    Somehow seems not to work in this case. Can you try also with a
    shorter down time for postgres server, like a normal restart? Would
    be intrested to see if the client side loses somehow connection
    parameters due to long time unconnected.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    On 1/14/11 11:15 AM, Javier Gallart wrote:
    <blockquote
      cite="mid:AANLkTimFEY_2yfZojgGwd5GAW+1NTOhd_7ihhJBiwsYd@mail.gmail.com"
      type="cite">Hi Daniel<br>
      <br>
      <br>
      this is my test:<br>
      <br>
      1- Kamailio starts and correctly loads the mtree <br>
      2- I make whatever modification in the tree and reload with
      mt_reload<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_dbase.c:153]: sending query ok: 0x92f880 - [select
      tname,tprefix,tvalue from mtree&nbsp; order by tname]<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:118]: allocate 48 bytes for result set at 0x94cd00<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_dbase.c:220]: 0x92f880 PQresultStatus(PGRES_TUPLES_OK)
      PQgetResult(0x29f05f0)<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_res.c:108]: 3 columns returned from the query<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:155]: allocate 24 bytes for result names at 0x94cc60<br>
      [....]<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_res.c:267]: freeing row buffer at 0x94c940<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: mtree
      [mtree.c:738]: adding new tname [1]<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:54]: freeing 3 rows<br>
      [...]<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:94]: freeing result names at 0x94cc60<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:99]: freeing result types at 0x94cbc0<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:136]: freeing result set at 0x94cd00<br>
      Jan 14 04:19:06 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_dbase.c:313]: PQclear(0x29f05f0) result set<br>
      <br>
      3. Postgres DB restarts (either through restart, or /stop/wait a
      minute/start)<br>
      No log is written in Kamailio when this happens.<br>
      <br>
      4.- I try again to reload the tree, and these are the logs:<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_dbase.c:153]: sending query ok: 0x92f880 - [select
      tname,tprefix,tvalue from mtree&nbsp; order by tname]<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:118]: allocate 48 bytes for result set at 0x94cd00<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: DEBUG: db_postgres
      [km_dbase.c:220]: 0x92f880 PQresultStatus(PGRES_FATAL_ERROR)
      PQgetResult(0x29ef0a0)<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: ERROR: db_postgres
      [km_dbase.c:236]: 0x92f880 - invalid query, execution aborted<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: ERROR: db_postgres
      [km_dbase.c:237]: 0x92f880 - PQresultStatus(PGRES_FATAL_ERROR)<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: ERROR: db_postgres
      [km_dbase.c:238]: 0x92f880: server closed the connection
      unexpectedly#012#011This probably means the server terminated
      abnormally#012#011before or while processing the request.#012<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:81]: freeing 0 columns<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: DEBUG: &lt;core&gt;
      [db_res.c:136]: freeing result set at 0x94cd00<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: ERROR: mtree
      [mtree_mod.c:633]: Error while fetching result<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: ERROR: db_postgres
      [km_dbase.c:329]: invalid parameter value<br>
      Jan 14 04:21:42 kam-test ./kamailio[31205]: ERROR: mtree
      [mtree_mod.c:744]: cannot re-load info from database<br>
      <br>
      Thanks in advance<br>
      <br>
      <br>
      Regards<br>
      <br>
      Javi<br>
      <br>
      <div class="gmail_quote">On Thu, Jan 13, 2011 at 1:56 PM,
        Daniel-Constantin Mierla <span dir="ltr">&lt;<a
            moz-do-not-send="true" href="mailto:miconda@gmail.com">miconda@gmail.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div bgcolor="#ffffff" text="#000000"> Can you send the log
            messages (debug=3) for that moment (restart of pg server and
            making a new call/registration)?<br>
            <br>
            Daniel
            <div>
              <div class="h5"><br>
                <br>
                On 1/13/11 12:00 PM, Javier Gallart wrote: </div>
            </div>
            <blockquote type="cite">
              <div>
                <div class="h5">Hi Daniel<br>
                  <br>
                  I have just tested it and I'm getting the same
                  results. This is the kamailio version I'm testing:<br>
                  root@kam-test:/usr/local/kamailio/sbin# ./kamailio -V<br>
                  version: kamailio 3.2.0-dev2 (x86_64/linux) 35568f<br>
                  <br>
                  Thanks!<br>
                  <br>
                  Javi<br>
                  <br>
                  <br>
                  <div class="gmail_quote">On Tue, Jan 4, 2011 at 3:46
                    PM, Javier Gallart <span dir="ltr">&lt;<a
                        moz-do-not-send="true"
                        href="mailto:jgallartm@gmail.com"
                        target="_blank">jgallartm@gmail.com</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin: 0pt
                      0pt 0pt 0.8ex; border-left: 1px solid rgb(204,
                      204, 204); padding-left: 1ex;"> Hi list
                      <div><br>
                      </div>
                      <div>we have been testing the mtree module. We do
                        periodical reloads of the mtree table with the
                        "mi mt_reload" command through xmlrpc. It works
                        fine except when the db is restarted. If we
                        manually restart the db and then try the
                        mt_reload commands we get this error:</div>
                      <div>
                        <div>Jan &nbsp;4 09:13:17
                          server&nbsp;/usr/local/kamailio-3.1.1/sbin/kamailio[28534]:
                          ERROR: db_postgres [km_dbase.c:152]: 0xa6a490
                          PQsendQuery Error: server closed the
                          connection unexpectedly#012#011This probably
                          means the server terminated
                          abnormally#012#011before or while processing
                          the request.#012 Query: select
                          partition,prefix,route from trees &nbsp;order by
                          partition</div>
                        <div>Jan &nbsp;4 09:13:17 server
                          /usr/local/kamailio-3.1.1/sbin/kamailio[28534]:
                          ERROR: &lt;core&gt; [db_query.c:101]: error
                          while submitting query</div>
                        <div>Jan &nbsp;4 09:13:17 server
                          /usr/local/kamailio-3.1.1/sbin/kamailio[28534]:
                          ERROR: mtree [mtree_mod.c:622]: Error while
                          querying db</div>
                        <div>Jan &nbsp;4 09:13:17 server
                          /usr/local/kamailio-3.1.1/sbin/kamailio[28534]:
                          ERROR: mtree [mtree_mod.c:738]: cannot re-load
                          info from database</div>
                      </div>
                      <div><br>
                      </div>
                      <div>Is there a way to reconnect to the db before
                        sending that command?</div>
                      <div><br>
                      </div>
                      <div>Thanks in advance</div>
                      <div><br>
                      </div>
                      <div>Regards</div>
                      <div><br>
                      </div>
                      <div>Javi</div>
                      <div><br>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
              <pre><fieldset></fieldset>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
            </blockquote>
            <div class="im"> <br>
              <pre cols="72">-- 
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
<a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a></pre>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</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>