#### Pre-Submission Checklist

- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, 
...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook 
files
in `doc/` subfolder, the README file is autogenerated)

#### Type Of Change
- [x] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)

#### Checklist:
- [x] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue

#### Description
When the `presence` module attempts to clean up records in the `presentity` 
table, it replaces the `etag` with a static, hardcoded string:
```
 "*#-OFFLINE-#*" 
```
However, the `presentity` table enforces a uniqueness constraint on the 
following combination of fields:

```
MariaDB [kamailio]> show create table presentity;
| presentity | CREATE TABLE `presentity` (
...
  UNIQUE KEY `presentity_idx` (`username`,`domain`,`event`,`etag`),
```
This approach breaks the uniqueness of etag, which is intended to differentiate 
records , especially in cases such as parallel calls, or when using kamailio as 
a forking proxy. 

Instead of overwriting the etag with the static offline marker, this patch 
appends the marker to the existing etag value. This ensures the offline flag is 
retained while preserving the uniqueness of the etag.

The deletion query was also updated accordingly: it now identifies offline 
records using a LIKE '%*#-OFFLINE-#*' clause.

Based on testing, the duplicate key errors no longer occur, and the cleanup 
logic now behaves as expected. This patch improves the reliability of 
presentity cleanup without requiring schema or index changes.

Please consider merging into master.

Thanks!


You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/4275

-- Commit Summary --

  * presence: preserve etag uniqueness when marking presentity for removal

-- File Changes --

    M src/modules/presence/presentity.c (90)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/4275.patch
https://github.com/kamailio/kamailio/pull/4275.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4275
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/pull/4...@github.com>
_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to