Currently i am trying to test mongodb for usrloc module of kamailio.
As expected kamailio is saving the contacts on DB.
However i am encountering a problem that the nathelper does not ping the registered contact on mongodb but when mysql is used it is ok even if ping_nated_only is set to 0.
If mysql:
```
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "use_domain", 0)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "db_ops_ruid", 1)
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 0)
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
```
if mongodb
```
modparam("usrloc", "db_url", MONGODBURL)
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "use_domain", 0)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "db_insert_null", 1)
modparam("usrloc", "db_ops_ruid", 1)
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 0)
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
```
```
version: kamailio 4.4.5 (x86_64/linux) f98162
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, 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: f98162
compiled on 08:56:05 Jan 10 2019 with gcc 4.6.3
```
Ah by the way only usrloc table is using mongodb, the rest of the module is using mysql, for testing only.
Can you advice if i am missing something?
Regards,
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1805
Add new function for getting the value of specific key in htable. if the key was expired, the type parameter's value will be set minus one.
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [ ] Commit message has the format required by CONTRIBUTING guide
- [ ] Commits are split per component (core, individual modules, libs, utils, ...)
- [ ] Each component has a single commit (if not, squash them into one commit)
- [ ] 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
- [ ] 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:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [ ] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1866
-- Commit Summary --
* htable: Add new function into htable_api
-- File Changes --
M src/modules/htable/api.c (14)
M src/modules/htable/api.h (3)
M src/modules/htable/ht_api.c (45)
M src/modules/htable/ht_api.h (2)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1866.patchhttps://github.com/kamailio/kamailio/pull/1866.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1866
#### Reproduction
run this script simultaneously (from two console for example)
```
#!/usr/bin/perl
$cmd = q(curl -X GET -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "dialplan.reload", "params":[], "id": 1 }' http://IP:PORT/jsonrpc/);
for ($i=0; $i<1000; $i++){
`$cmd`;
}
```
#### Debugging Data
```
Program terminated with signal 11, Segmentation fault.
#0 0x00007ffaa39e95f7 in add_rule2hash (rule=0x7ffa9fa05248, h_index=1) at dp_db.c:563
/home/snen/KamailioGitMyFork/src/modules/dialplan/dp_db.c:563:12474:beg:0x7ffaa39e95f7
(gdb) bt
#0 0x00007ffaa39e95f7 in add_rule2hash (rule=0x7ffa9fa05248, h_index=1) at dp_db.c:563
#1 0x00007ffaa39e4831 in dp_load_db () at dp_db.c:305
#2 0x00007ffaa39ce914 in dialplan_rpc_reload (rpc=0x7ffa9f382a80 <func_param>, ctx=0x7ffa9f3829a0 <_jsonrpc_ctx_global>) at dialplan.c:610
#3 0x00007ffa9f16398f in jsonrpc_dispatch (msg=0x7ffd427ad880, s1=0x0, s2=0x0) at jsonrpcs_mod.c:1294
#4 0x0000000000461a5f in do_action (h=0x7ffd427ad7a0, a=0x7ffaa72987d8, msg=0x7ffd427ad880) at core/action.c:1067
#5 0x000000000046e23e in run_actions (h=0x7ffd427ad7a0, a=0x7ffaa72987d8, msg=0x7ffd427ad880) at core/action.c:1564
#6 0x00000000004619ce in do_action (h=0x7ffd427ad7a0, a=0x7ffaa729b140, msg=0x7ffd427ad880) at core/action.c:1058
#7 0x000000000046e23e in run_actions (h=0x7ffd427ad7a0, a=0x7ffaa729b140, msg=0x7ffd427ad880) at core/action.c:1564
#8 0x00007ffa9f38868c in xhttp_process_request (orig_msg=0x7ffaa72a6ed0,
new_buf=0x7ffaa72c4420 "GET /jsonrpc/ HTTP/1.1\r\nVia: SIP/2.0/TCP 192.168.10.190:48542\r\nUser-Agent: curl/7.29.0\r\nHost: 192.168.10.190:5071\r\nAccept: */*\r\nContent-Type: application/json\r\nContent-Length: 71\r\n\r\n{\"jsonrpc\": \"2.0\","..., new_len=253) at xhttp_mod.c:296
#9 0x00007ffa9f389dcf in xhttp_handler (msg=0x7ffaa72a6ed0) at xhttp_mod.c:383
#10 0x00000000004ff30c in nonsip_msg_run_hooks (msg=0x7ffaa72a6ed0) at core/nonsip_hooks.c:112
#11 0x000000000057b373 in receive_msg (
buf=0x7ffaa02ec618 "GET /jsonrpc/ HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nHost: 192.168.10.190:5071\r\nAccept: */*\r\nContent-Type: application/json\r\nContent-Length: 71\r\n\r\n{\"jsonrpc\": \"2.0\", \"method\": \"dialplan.reload\", \"params\":"..., len=214, rcv_info=0x7ffaa02ec338) at core/receive.c:270
#12 0x0000000000635eb5 in receive_tcp_msg (
tcpbuf=0x7ffaa02ec618 "GET /jsonrpc/ HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nHost: 192.168.10.190:5071\r\nAccept: */*\r\nContent-Type: application/json\r\nContent-Length: 71\r\n\r\n{\"jsonrpc\": \"2.0\", \"method\": \"dialplan.reload\", \"params\":"..., len=214, rcv_info=0x7ffaa02ec338, con=0x7ffaa02ec320) at core/tcp_read.c:1399
#13 0x0000000000638372 in tcp_read_req (con=0x7ffaa02ec320, bytes_read=0x7ffd427ae65c, read_flags=0x7ffd427ae658) at core/tcp_read.c:1631
#14 0x000000000063b115 in handle_io (fm=0x7ffaa7302d78, events=1, idx=-1) at core/tcp_read.c:1804
#15 0x00000000006299b6 in io_wait_loop_epoll (h=0xae9060 <io_w>, t=2, repeat=0) at core/io_wait.h:1062
#16 0x000000000063d172 in tcp_receive_loop (unix_sock=16) at core/tcp_read.c:1974
#17 0x00000000004dcaf9 in tcp_init_children () at core/tcp_main.c:5086
#18 0x00000000004266c4 in main_loop () at main.c:1750
#19 0x000000000042d14b in main (argc=13, argv=0x7ffd427aedc8) at main.c:2737
(gdb) l
558 new_id = 0;
559
560 /*search for the corresponding dpl_id*/
561 for(crt_idp = last_idp =rules_hash[h_index]; crt_idp!= NULL;
562 last_idp = crt_idp, crt_idp = crt_idp->next)
563 if(crt_idp->dp_id == rule->dpid)
564 break;
565
566 /*didn't find a dpl_id*/
567 if(!crt_idp){
(gdb) p crt_idp->dp_id
Cannot access memory at address 0x7ffa9f002429
(gdb)
```
### Additional Information
```
kamailio 5.3.0-dev3 (x86_64/linux) d726bd
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1874
### Description
When restarting kamailio nodes in our infrastructure we noticed that under traffic some nodes started using the 100% of the CPU, with the precious help of @giavac we were able to track down the issue to an infinite loop inside the htable module when synchronizing somewhat big (60K) htables via dmq
### Troubleshooting
#### Reproduction
Have 1 kamailio instance with a 60K+ htable and start a new instance, the first instance will try to send the whole table to the new instance and it will enter an infinite loop which consumes 100% of the CPU
This is caused by a double call to **ht_dmq_cell_group_flush** which creates a circular list on the json structure hierarchy, the second call happens in this block of code (hence why it's required a 60K htable):
https://github.com/kamailio/kamailio/blob/5.2/src/modules/htable/ht_dmq.c#L…
When this happens **ht_dmq_cell_group_flush** try to add **ht_dmq_jdoc_cell_group.jdoc_cells** inside **ht_dmq_jdoc_cell_group.jdoc->root** but this root already has **json_cells** as its child
so when **srjson_AddItemToObject** is called (and in turn **srjson_AddItemToArray**) it gets appended as the child of itself:
https://github.com/kamailio/kamailio/blob/master/src/lib/srutils/srjson.c#L…
This circular structure then causes a loop when calling **srjson_PrintUnformatted** because in the **print_object** function the circular list is looped over:
https://github.com/kamailio/kamailio/blob/master/src/lib/srutils/srjson.c#L…
### Possible Solutions
One possible solution could be to destroy and init again the **ht_dmq_jdoc_cell_group** structure after calling the flush:
```
if (ht_dmq_jdoc_cell_group.size >= dmq_cell_group_max_size) {
LM_DBG("sending group count[%d]size[%d]\n", ht_dmq_jdoc_cell_group.count, ht_dmq_jdoc_cell_group.size);
if (ht_dmq_cell_group_flush(node) < 0) {
ht_slot_unlock(ht, i);
goto error;
}
ht_dmq_cell_group_destroy();
ht_dmq_cell_group_init();
}
```
But we are not sure about the performance implications.
### Additional Information
`# kamailio -v
version: kamailio 5.2.1 (x86_64/linux) 44e488
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, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, 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_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 44e488
compiled on 11:52:58 Feb 21 2019 with gcc 5.4.0
`
* **Operating System**:
ubuntu:xenial docker container
`# uname -a
Linux kama-0 4.4.0-135-generic #161-Ubuntu SMP Mon Aug 27 10:45:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux`
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1863
- reported by Enrico Bandiera (GH #1863)
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [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:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [X] PR should be backported to stable branches
- [X] Tested changes locally
- [X] Related to issue #1863 (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1872
-- Commit Summary --
* htable: fix infinite loop during dmq sync of large tables
-- File Changes --
M src/modules/htable/ht_dmq.c (27)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1872.patchhttps://github.com/kamailio/kamailio/pull/1872.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1872