<p>We are using the <code>presence</code> module and have noticed many errors in the log as follows:<br>
<code>WARNING: db_postgres [km_dbase.c:240]: db_postgres_submit_query(): postgres result check failed with code 7 (PGRES_FATAL_ERROR)<br>
WARNING: db_postgres [km_dbase.c:244]: db_postgres_submit_query(): postgres query command failed, connection status 0, error [ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(user+test2, phonedev.test2.io, dialog, *#-OFFLINE-#*) already exists.#012]</code></p>

<p>I looked over the <code>presentity.c</code> code and it appears that the module is marking the records for deletion once they expire by setting the <code>etag</code> to <code>*#-OFFLINE-#*</code></p>

<p>This is triggering the postgres constraint and throwing the error. I am confused why the module is using the <code>etag</code> column to mark for deletion since it is part of a constraint. Why not add a new column such as <code>delete_record</code> and set it to true?</p>

<p>If there is no good reason for this, I would like to propose a patch to add said column.<br>
Please let me know if I am misunderstanding anything here, thanks.<br>
Emmanuel</p>

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