{"action":"created","issue":{"url":"https://api.github.com/repos/kamailio/kamailio/issues/600","repository_url":"https://api.github.com/repos/kamailio/kamailio","labels_url":"https://api.github.com/repos/kamailio/kamailio/issues/600/labels{/name}","comments_url":"https://api.github.com/repos/kamailio/kamailio/issues/600/comments","events_url":"https://api.github.com/repos/kamailio/kamailio/issues/600/events","html_url":"https://github.com/kamailio/kamailio/issues/600","id":153298286,"number":600,"title":"presence module triggering postgres constraint when marking records for deletion","user":{"login":"eschmidbauer","id":7139998,"avatar_url":"https://avatars.githubusercontent.com/u/7139998?v=3","gravatar_id":"","url":"https://api.github.com/users/eschmidbauer","html_url":"https://github.com/eschmidbauer","followers_url":"https://api.github.com/users/eschmidbauer/followers","following_url":"https://api.github.com/users/eschmidbauer/following{/other_user}","gists_url":"https://api.github.com/users/eschmidbauer/gists{/gist_id}","starred_url":"https://api.github.com/users/eschmidbauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eschmidbauer/subscriptions","organizations_url":"https://api.github.com/users/eschmidbauer/orgs","repos_url":"https://api.github.com/users/eschmidbauer/repos","events_url":"https://api.github.com/users/eschmidbauer/events{/privacy}","received_events_url":"https://api.github.com/users/eschmidbauer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-05T18:52:59Z","updated_at":"2016-05-06T12:08:38Z","closed_at":null,"body":"We are using the `presence` module and have noticed many errors in the log as follows:\r\n```WARNING: db_postgres [km_dbase.c:240]: db_postgres_submit_query(): postgres result check failed with code 7 (PGRES_FATAL_ERROR)\r\nWARNING: 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]```\r\n\r\nI looked over the `presentity.c` code and it appears that the module is marking the records for deletion once they expire by setting the `etag` to `*#-OFFLINE-#*`\r\n\r\nThis is triggering the postgres constraint and throwing the error. I am confused why the module is using the `etag` column to mark for deletion since it is part of a constraint. Why not add a new column such as `delete_record` and set it to true?\r\n\r\nIf there is no good reason for this, I would like to propose a patch to add said column.\r\nPlease let me know if I am misunderstanding anything here, thanks.\r\nEmmanuel"},"comment":{"url":"https://api.github.com/repos/kamailio/kamailio/issues/comments/217423673","html_url":"https://github.com/kamailio/kamailio/issues/600#issuecomment-217423673","issue_url":"https://api.github.com/repos/kamailio/kamailio/issues/600","id":217423673,"user":{"login":"miconda","id":184809,"avatar_url":"https://avatars.githubusercontent.com/u/184809?v=3","gravatar_id":"","url":"https://api.github.com/users/miconda","html_url":"https://github.com/miconda","followers_url":"https://api.github.com/users/miconda/followers","following_url":"https://api.github.com/users/miconda/following{/other_user}","gists_url":"https://api.github.com/users/miconda/gists{/gist_id}","starred_url":"https://api.github.com/users/miconda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miconda/subscriptions","organizations_url":"https://api.github.com/users/miconda/orgs","repos_url":"https://api.github.com/users/miconda/repos","events_url":"https://api.github.com/users/miconda/events{/privacy}","received_events_url":"https://api.github.com/users/miconda/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T12:08:38Z","updated_at":"2016-05-06T12:08:38Z","body":"@eschmidbauer: make a pull request, to be easier to review over all. You can make pull requests from branches of kamailio, no need to clone repo."}}