<p>Hello,</p>
<p>I can reproduce the issue, with kamailio 4.4.6+jessie from kamailio debian repository:</p>
<ul>
<li>0x04 flag is set on save()</li>
<li>old contacts are deleted on the server receiving the REGISTER message</li>
<li>old contacts are not deleted on servers being notified via DMQ</li>
</ul>
<p>server1 (REGISTER message):</p>
<blockquote>
<p>DEBUG: usrloc [ucontact.c:1692]: update_ucontact(): exists callback for type= UL_CONTACT_UPDATE<br>
DEBUG: usrloc [ul_callback.h:84]: run_ul_callbacks(): contact=0x7f0096e0b548, callback type 2/15, id 0 entered<br>
DEBUG: dmq_usrloc [usrloc_sync.c:578]: dmq_ul_cb_contact(): Callback from usrloc with type=2<br>
DEBUG: dmq_usrloc [usrloc_sync.c:548]: usrloc_dmq_send_contact(): sending serialized data {"action":1,"aor":"+33564093848","ruid":"uloc-5a86b8c5-31e0-2","c":"sip:+33564093848@xxx:41502;ob","received":"","path":"","callid":"ntoWjs3R3WpP9Z5rsi7Npmr2rRGKstls","user_agent":"CSipSimple_porridge-23/r2457","instance":"","expires":1518779539,"cseq":55952,"flags":0,"cflags":0,"q":-1,"last_modified":1518778639,"methods":8159,"reg_id":0}<br>
DEBUG: dmq_usrloc [usrloc_sync.c:299]: usrloc_dmq_send(): sending dmq broadcast...</p>
</blockquote>
<p>server2 (DMQ recipient):</p>
<blockquote>
<p>DEBUG: dmq_usrloc [usrloc_sync.c:327]: usrloc_dmq_handle_msg(): dmq message received from sip:usrloc@172.16.67.15:5060<br>
DEBUG: dmq_usrloc [usrloc_sync.c:429]: usrloc_dmq_handle_msg(): Received DMQ_UPDATE. Update contact info...<br>
DEBUG: dmq_usrloc [usrloc_sync.c:64]: add_contact(): aor: +33564093848<br>
DEBUG: dmq_usrloc [usrloc_sync.c:65]: add_contact(): ci->ruid: uloc-5a86b8c5-31e0-2<br>
DEBUG: dmq_usrloc [usrloc_sync.c:66]: add_contact(): aorhash: -1799456359<br>
DEBUG: dmq_usrloc [usrloc_sync.c:72]: add_contact(): Found contact<br>
DEBUG: usrloc [ucontact.c:1692]: update_ucontact(): exists callback for type= UL_CONTACT_UPDATE<br>
DEBUG: usrloc [ul_callback.h:84]: run_ul_callbacks(): contact=0x7f3900243bd0, callback type 2/15, id 0 entered<br>
DEBUG: dmq_usrloc [usrloc_sync.c:578]: dmq_ul_cb_contact(): Callback from usrloc with type=2<br>
DEBUG: dmq_usrloc [usrloc_sync.c:600]: dmq_ul_cb_contact(): Contact received from DMQ... skip<br>
DEBUG: usrloc [ucontact.c:1004]: db_update_ucontact_ruid(): ruid:uloc-5a86b8c5-31e0-2<br>
DEBUG: usrloc [ucontact.c:1133]: db_update_ucontact_ruid(): contact:sip:+33564093848@xxx:41502;ob<br>
DEBUG: dmq_usrloc [usrloc_sync.c:74]: add_contact(): Release record<br>
DEBUG: dmq_usrloc [usrloc_sync.c:76]: add_contact(): Unlock udomain</p>
</blockquote>
<p>the recipient receive an UPDATE message only.<br>
according to usrloc_sync.c:usrloc_dmq_handle_msg(), UPDATE message add the new contact only (execute add_contact()), but the other one is not deleted</p>
<p>and there is no DMQ_RM message generated from the emitter</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you commented.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/265#issuecomment-366211445">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZafdNafP3FDmsDP1903Ab_B7GBdsks5tVWY4gaJpZM4Fe-Ug">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZUhU61-ssqF140qhat3RkmeTF26Kks5tVWY4gaJpZM4Fe-Ug.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/265#issuecomment-366211445"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@gbour in #265: Hello,\r\n\r\nI can reproduce the issue, with kamailio 4.4.6+jessie from kamailio debian repository:\r\n* 0x04 flag is set on save()\r\n* old contacts are deleted on the server receiving the REGISTER message\r\n* old contacts are not deleted on servers being notified via DMQ\r\n\r\n\r\n\r\n\r\nserver1 (REGISTER message):\r\n\u003e DEBUG: usrloc [ucontact.c:1692]: update_ucontact(): exists callback for type= UL_CONTACT_UPDATE\r\n\u003e DEBUG: usrloc [ul_callback.h:84]: run_ul_callbacks(): contact=0x7f0096e0b548, callback type 2/15, id 0 entered\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:578]: dmq_ul_cb_contact(): Callback from usrloc with type=2\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:548]: usrloc_dmq_send_contact(): sending serialized data {\"action\":1,\"aor\":\"+33564093848\",\"ruid\":\"uloc-5a86b8c5-31e0-2\",\"c\":\"sip:+33564093848@xxx:41502;ob\",\"received\":\"\",\"path\":\"\",\"callid\":\"ntoWjs3R3WpP9Z5rsi7Npmr2rRGKstls\",\"user_agent\":\"CSipSimple_porridge-23/r2457\",\"instance\":\"\",\"expires\":1518779539,\"cseq\":55952,\"flags\":0,\"cflags\":0,\"q\":-1,\"last_modified\":1518778639,\"methods\":8159,\"reg_id\":0}\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:299]: usrloc_dmq_send(): sending dmq broadcast...\r\n\r\nserver2 (DMQ recipient):\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:327]: usrloc_dmq_handle_msg(): dmq message received from sip:usrloc@172.16.67.15:5060\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:429]: usrloc_dmq_handle_msg(): Received DMQ_UPDATE. Update contact info...\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:64]: add_contact(): aor: +33564093848\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:65]: add_contact(): ci-\u003eruid: uloc-5a86b8c5-31e0-2\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:66]: add_contact(): aorhash: -1799456359\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:72]: add_contact(): Found contact\r\n\u003e DEBUG: usrloc [ucontact.c:1692]: update_ucontact(): exists callback for type= UL_CONTACT_UPDATE\r\n\u003e DEBUG: usrloc [ul_callback.h:84]: run_ul_callbacks(): contact=0x7f3900243bd0, callback type 2/15, id 0 entered\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:578]: dmq_ul_cb_contact(): Callback from usrloc with type=2\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:600]: dmq_ul_cb_contact(): Contact received from DMQ... skip\r\n\u003e DEBUG: usrloc [ucontact.c:1004]: db_update_ucontact_ruid(): ruid:uloc-5a86b8c5-31e0-2\r\n\u003e DEBUG: usrloc [ucontact.c:1133]: db_update_ucontact_ruid(): contact:sip:+33564093848@xxx:41502;ob\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:74]: add_contact(): Release record\r\n\u003e DEBUG: dmq_usrloc [usrloc_sync.c:76]: add_contact(): Unlock udomain\r\n\r\n\r\nthe recipient receive an UPDATE message only.\r\naccording to usrloc_sync.c:usrloc_dmq_handle_msg(), UPDATE message add the new contact only (execute add_contact()), but the other one is not deleted\r\n\r\nand there is no DMQ_RM message generated from the emitter"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/265#issuecomment-366211445"}}}</script>