Hello. I'm testing module presence with pua and pua_usrloc. Unfortunately, despite turning off (db_mode 0) writing to DB, it does. With no luck, because `db_sqlite_commit` return ERROR. Bellow logs of this operation:
``` Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: presence [publish.c:75]: msg_presentity_clean(): cleaning expired presentity information Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: select username,domain,etag,event from presentity where expires<?1 AND expires>?2 order by us ername Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: <core> [db_res.c:116]: db_new_result(): allocate 56 bytes for result set at 0x7f086c1428c0 Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: presence [publish.c:116]: msg_presentity_clean(): found n= 0 expires messages#012 Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 0 columns Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: <core> [db_res.c:134]: db_free_result(): freeing result set at 0x7f086c1428c0 Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: delete from presentity where expires<?1 AND expires>?2 Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: presence [subscribe.c:734]: msg_watchers_clean(): cleaning pending subscriptions Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: delete from watchers where inserted_time<?1 AND status=?2 Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: presence [subscribe.c:2318]: timer_db_update(): db_update timer Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: presence [subscribe.c:1984]: update_db_subs_timer_dbnone(): update_db_subs_timer_dbnone: start Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: pua [pua.c:1098]: db_update(): INSERTDB_FLAG Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: insert into pua (pres_uri,pres_id,flag,event,watcher_uri,call_id,to_tag,from_tag,etag,tuple_i d,cseq,expires,desired_expires,record_route,contact,remote_contact,version,extra_headers ) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18) Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: ERROR: db_sqlite [dbase.c:489]: db_sqlite_commit(): sqlite commit failed: NOT NULL constraint failed: pua.call_id Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: ERROR: db_sqlite [dbase.c:138]: db_sqlite_cleanup_query(): finalize failed: NOT NULL constraint failed: pua.call_id Sep 24 12:40:18 f76fd4ccce03 kamailio[305]: ERROR: pua [pua.c:1179]: db_update(): while inserting in db table pua ```
My pua configuration: ``` modparam("pua", "db_url", PUADBURL) modparam("pua", "db_mode", 0) modparam("pua", "db_table_lock_write", 0) modparam("pua", "outbound_proxy", "sip:127.0.0.1") ``` pua_usrloc: ``` modparam("pua_usrloc", "default_domain", SIPDOMAIN) modparam("pua_usrloc", "entity_prefix", "sip") modparam("pua_usrloc", "branch_flag", FLB_USRLOC) ``` presence: ``` modparam("presence", "db_url", PRESENCEDBURL) modparam("presence", "subs_db_mode", 0) modparam("presence", "publ_cache", 0) modparam("presence", "db_table_lock_type", 0) ```
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345
Can you try with the patch from commit ad552d4e45a8311d50444d76e9862d40421e1715 or with the master branch?
Send again the output from syslog with debug=3, because the patch is manly targeting to see if the call-id field in the pua structure is not set, which should be.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-153387020
It seems that callid is empty. Output after applying patch: ``` Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: presence [publish.c:75]: msg_presentity_clean(): cleaning expired presentity information Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: select username,domain,etag,event from presentity where expires<?1 AND expires>?2 order by username Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: <core> [db_res.c:116]: db_new_result(): allocate 56 bytes for result set at 0x7fb7c2b94c30 Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: presence [publish.c:116]: msg_presentity_clean(): found n= 0 expires messages#012 Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 0 columns Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: <core> [db_res.c:134]: db_free_result(): freeing result set at 0x7fb7c2b94c30 Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: delete from presentity where expires<?1 AND expires>?2 Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: presence [subscribe.c:734]: msg_watchers_clean(): cleaning pending subscriptions Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: delete from watchers where inserted_time<?1 AND status=?2 Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: presence [subscribe.c:2318]: timer_db_update(): db_update timer Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: presence [subscribe.c:1984]: update_db_subs_timer_dbnone(): update_db_subs_timer_dbnone: start Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: pua [pua.c:1098]: db_update(): INSERTDB_FLAG Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: pua [pua.c:1106]: db_update(): p->callid is empty Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: insert into pua (pres_uri,pres_id,flag,event,watcher_uri,call_id,to_tag,from_tag,etag,tuple_id,cseq,expires,desired_expires,record_route,contact,remote_contact,version,extra_headers ) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18) Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: ERROR: db_sqlite [dbase.c:489]: db_sqlite_commit(): sqlite commit failed: NOT NULL constraint failed: pua.from_tag Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: ERROR: db_sqlite [dbase.c:138]: db_sqlite_cleanup_query(): finalize failed: NOT NULL constraint failed: pua.from_tag Nov 3 15:54:51 b6174a49bae4 kamailio[2539]: ERROR: pua [pua.c:1186]: db_update(): while inserting in db table pua ```
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-153397799
just to chime in on this ticket, I am also seeing this same behaviour.
Kamailio version: ``` version: kamailio 4.3.4 (x86_64/linux) 0ec860 flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, DBG_QM_MALLOC, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: 0ec860 compiled on 17:42:12 Nov 25 2015 with gcc 4.4.7 ```
Sample log message: ``` Dec 18 10:27:13 kam_proxy01[25942]: ERROR: db_sqlite [dbase.c:489]: db_sqlite_commit(): sqlite commit failed: constraint failed Dec 18 10:27:13 kam_proxy01[25942]: ERROR: db_sqlite [dbase.c:138]: db_sqlite_cleanup_query(): finalize failed: pua.call_id may not be NULL Dec 18 10:27:13 kam_proxy01[25942]: ERROR: pua [pua.c:1179]: db_update(): while inserting in db table pua ```
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-165742196
Hi Daniel!
have the same errors in logs (as in first post) in kamailio-4.2.5 Tried your patch suggested here, have [the same result as sternik](https://github.com/kamailio/kamailio/issues/345#issuecomment-153397799)
Added the check for "from_tag", now my test code looks like:
``` --- pua.c (revision 30772) +++ pua.c (working copy) @@ -1112,8 +1112,24 @@ q_vals[puri_col].val.str_val = *(p->pres_uri); q_vals[pid_col].val.str_val = p->id; q_vals[flag_col].val.int_val = p->flag; - q_vals[callid_col].val.str_val = p->call_id; - q_vals[fromtag_col].val.str_val = p->from_tag; + + if(p->call_id.s) { + LM_DBG("p->callid = %.*s\n", p->call_id.len, p->call_id.s); + q_vals[callid_col].val.str_val = p->call_id; + } else { + LM_DBG("p->callid is empty\n"); + q_vals[callid_col].val.str_val.s = ""; + q_vals[callid_col].val.str_val.len = 0; + } + if(p->from_tag.s) { + LM_DBG("p->from_tag = %.*s\n", p->from_tag.len, p->from_tag.s); + q_vals[fromtag_col].val.str_val = p->from_tag; + } else { + LM_DBG("p->from_tag is empty\n"); + q_vals[fromtag_col].val.str_val.s = ""; + q_vals[fromtag_col].val.str_val.len = 0; + } + ```
testing this I get read of initial errors, now the log looks like:
``` Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: pua [pua.c:1111]: db_update(): INSERTDB_FLAG Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: pua [pua.c:1119]: db_update(): p->callid is empty Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: pua [pua.c:1131]: db_update(): p->from_tag is empty Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: insert into pua (pres_uri,pres_id,flag,event,watcher_uri,call_id,to_tag,from_tag,etag,tuple_id,cseq,expires,desired_expires,record_route,contact,remote_contact,version,extra_headers ) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18) Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: pua [pua.c:1111]: db_update(): INSERTDB_FLAG Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: pua [pua.c:1119]: db_update(): p->callid is empty Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: pua [pua.c:1131]: db_update(): p->from_tag is empty Dec 18 15:35:58 /usr/sbin/kamailio[15101]: DEBUG: db_sqlite [dbase.c:183]: db_sqlite_submit_query(): submit_query: insert into pua (pres_uri,pres_id,flag,event,watcher_uri,call_id,to_tag,from_tag,etag,tuple_id,cseq,expires,desired_expires,record_route,contact,remote_contact,version,extra_headers ) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18) ```
Now, as I understood, the suggested patch, is not for release usage? Do you have explanation, why the callid and from_tag could be empty? Do you need any additional info or testing?
Cheers!
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-165793474
Pushed a patch to test from_tag field as well. it seems that sqlite module doesn't like null pointers to string values which are going to not-null constraints.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-174341618
Closed #345.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#event-524355956
Hi Daniel! Sorry for the noise, but can you point out to the patch for this issue?
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-174484913
Last patch on pua module - 3331bf3e0b81366f21a7eccf19cfc650e721fb95
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/345#issuecomment-174489690