OpenSIPS version you are running
version: opensips 4.0.0 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, F_PARALLEL_MALLOC, DBG_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
git revision: unknown
Describe the bug
A buggy UA exposes an Opensips bug. The UA often does not refresh it's presentity ( missing SIP-If-Match header ) rather it publishes a new one. Without refresh the presentity will expire. Opensips cleans expired presentities periodically. This entails deleting the presentity from phtable and presentity DB. This appears to complete but a manual check of the presentity DB shows it remains. The presentity is however removed from phtable.
Eventually opensips cleans the presentities again. This time it sees the same expired presentity and again attempts to delete it from the DB and phtable. This time it successfully deletes the presentity from the DB but the attempt to delete it from phtable fails because it was deleted previously. This results in ----
ERROR:presence:delete_phtable_query: Record not found
ERROR:presence:msg_presentity_clean: deleting from pres hash table
**To Reproduce**
Steps to reproduce
1. Observe error logs
**Expected behavior**
Expired presentities should deleted without creating erro logs.
**Relevant System Logs**
<!--
Please provide, in ticks block, relevant information from the system logs
-->
```
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:msg_presentity_clean: cleaning expired presentity information
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:core:db_new_result: allocate 48 bytes for result set at 0x7f88ffd7f338
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:db_sqlite:db_sqlite_get_columns: 4 columns returned from the query
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:core:db_allocate_columns: allocate 112 bytes for result columns at 0x7f88ffd7d730
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:db_sqlite:db_sqlite_get_columns: RES_NAMES(0x7f88ffd7d750)[0]=[username]
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:db_sqlite:db_sqlite_get_columns: RES_NAMES(0x7f88ffd7d760)[1]=[domain]
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:db_sqlite:db_sqlite_get_columns: RES_NAMES(0x7f88ffd7d770)[2]=[etag]
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:db_sqlite:db_sqlite_get_columns: RES_NAMES(0x7f88ffd7d780)[3]=[event]
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:msg_presentity_clean: found n= 1 expires messages
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:search_event: start event= [presence]
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:core:db_free_columns: freeing result columns at 0x7f88ffd7d730
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:msg_presentity_clean: found expired publish for [user]=7 [domain]=192.168.1.2
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:get_subs_dialog: found 0 dialogs
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:publ_notify: Could not find subs_dialog
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:msg_presentity_clean: Delete it from the hash table
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:search_phtable_etag: pres_uri= sip:7@192.168.1.2, event=1, etag= a.1785956694.381389.2.1
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:search_phtable_etag: found etag = a.1785956694.381389.5.0
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: DBG:presence:search_phtable_etag: found etag = a.1785956694.381389.3.0
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: ERROR:presence:delete_phtable_query: Record not found [a.1785956694.381389.2.1]
Aug 05 12:31:34 slim.mylan /usr/local/sbin/opensips[381389]: ERROR:presence:msg_presentity_clean: deleting from pres hash table
```
**OS/environment information**
- Operating System: Fedora 44
- OpenSIPS installation: From git
- other relevant information:
**Additional context**
<!-- Add any other context about the problem here. -->
DB and phtable queries can be provided if needed.
OpenSIPS version you are running
Describe the bug
A buggy UA exposes an Opensips bug. The UA often does not refresh it's presentity ( missing SIP-If-Match header ) rather it publishes a new one. Without refresh the presentity will expire. Opensips cleans expired presentities periodically. This entails deleting the presentity from phtable and presentity DB. This appears to complete but a manual check of the presentity DB shows it remains. The presentity is however removed from phtable.
Eventually opensips cleans the presentities again. This time it sees the same expired presentity and again attempts to delete it from the DB and phtable. This time it successfully deletes the presentity from the DB but the attempt to delete it from phtable fails because it was deleted previously. This results in ----