<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hello,</p>
    <p>indeed, the location_attrs should be deleted along with the
      contact records.</p>
    <p>What db_mode value you use for usrloc module?</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 20/02/2017 10:17, Mridul B wrote:<br>
    </div>
    <blockquote
cite="mid:CA+zJJFK=hE3xDmjUHBRtYUnfaeFcwYP_SaVUCCvLd9DQJfuv5A@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">Hi,
            <div><br>
            </div>
            <div>We've noticed a case where the <b>location_attrs</b>
              table isn't updated when there's an unexpected shutdown of
              a SIP device (here there'll be no REGISTER message sent
              with expires=0). </div>
            <div><br>
            </div>
            <div>We're using Kamailio v4.3.x</div>
            <div><br>
            </div>
            <div>When the SIP device shuts down ungracefully. The
              location table is updated using DELETE query</div>
            <div>This is done by the timer which deletes the expired
              contacts, by default the timer_interval is set as 60.</div>
            <div><br>
            </div>
            <div>Here, the logs of auto-removal of expired contacts
              entries by the timer</div>
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex"><br>
              Feb 17 17:16:13 localhost kamailio[23273]: DEBUG:
              db_postgres [km_dbase.c:272]: db_postgres_submit_query():
              sending query ok: 0x7f34969433c8 (1) - [delete from
              location where expires<'2017-02-17 17:16:14' AND
              expires<>'1970-01-01 00:00:00']<br>
            </blockquote>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex"> </blockquote>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">Feb 17 17:16:14
              localhost kamailio[23272]: DEBUG: db_postgres
              [km_dbase.c:272]: db_postgres_submit_query(): sending
              query ok: 0x7f34969433c8 (1) - [delete from location where
              expires<'2017-02-17 17:16:15' AND
              expires<>'1970-01-01 00:00:00'] </blockquote>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex"> </blockquote>
            <div><br>
            </div>
            <div>The delete operation is only on location table,
              shouldn't we have the same implementation on the
              location_attrs table based upon ruid or username?</div>
            <div><br>
            </div>
            <div>We're getting duplicate entries in the location_attrs
              table of the same sip user after it registers.</div>
            <div><br>
            </div>
            <div>But when the SIP device un-registers, the entries in
              the location as well as in the location_attrs table is
              deleted</div>
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">Feb 17 18:14:32
              localhost kamailio[23249]: DEBUG: usrloc
              [ucontact.c:1725]: uldb_delete_attrs(): trying to delete
              location attributes<br>
              Feb 17 18:14:32 localhost kamailio[23249]: DEBUG:
              db_postgres [km_dbase.c:272]: db_postgres_submit_query():
              sending query ok: 0x7f3496941888 (1) - [delete from
              location_attrs where username='mridul' AND
              ruid='uloc-58a72243-5ace-2']<br>
            </blockquote>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex"> </blockquote>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">Feb 17 18:14:32
              localhost kamailio[23249]: DEBUG: db_postgres
              [km_dbase.c:272]: db_postgres_submit_query(): sending
              query ok: 0x7f3496941888 (1) - [delete from location where
              username='mridul' AND contact='<a moz-do-not-send="true"
                href="mailto:sip%3Amridul@127.0.0.1">sip:mridul@127.0.0.1</a>:<wbr>37881;rinstance=<wbr>b841a8c916e47dfa']</blockquote>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>I think the usrloc module should have the
              implementation of deleting the entries of expired sip
              users based on its ruid/username in the location_attrs
              table also.</div>
            <div><br>
            </div>
            <div>Thanks for the help.</div>
            <div><br clear="all">
              <div>
                <div class="m_4978146786914061378gmail_signature">
                  <div dir="ltr">
                    <div dir="ltr">
                      <div dir="ltr">
                        <div dir="ltr">
                          <div dir="ltr">
                            <div dir="ltr">
                              <div dir="ltr">
                                <div dir="ltr">
                                  <div><span
                                      style="font-family:arial;font-size:12px">Best
                                      regards,</span></div>
                                  MRIDUL</div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
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
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 8-10, 2017 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>