<p>I think this is not easy to track as long as the MySQL made the insert but the client reports an error for doing the insert. So mysql client says the insert didn't succeed, but the mysql server actually did it.</p>

<p>There can be added some self healing approaches:</p>

<ul>
<li>1)add a timer function to delete expired records from database, so this situation will stay there only for the duration of one registration interval</li>
<li>2) if insert fails, try to figure out if the driver reports a duplicate key, if yes, then do a query and load the record from db with same ruid and if other attributes matches the structure in memory, then either remove it from db (maybe it has some too old details, then next insert should succeed) or set the structure in memory to do update next time</li>
<li>3) if insert in db fails, try to do a remove from db at that time </li>
</ul>

<p>What I wanted to figure out is whether the unique id generation used for ruid can result in duplication, which should not happen by its algorithm and it is not the reason for the reported issue here. In other words, you don't report here that Kamailio generates same ruid value for different location records.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/30#issuecomment-160119895">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36Za9mnRQx0_wtanOokxNCFRjFcV7Wks5pKDaggaJpZM4DRc8s.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/30#issuecomment-160119895"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>