### Description
We are running Kamailio 5.1.x in a mixed native/Kemi environment. That means, most of the config is still native Kamailio language, but some newer functions were written in JS and included via `jsdt_run("...");`.
In one of those functions, we place an sqlops query. And since introducing this code, Kamailio leaks memory. Slowly, but eventually, the private memory will fill up.
### Troubleshooting
#### Reproduction
In Kamailio, the code looks like this:
```
if (!jsdt_run("ksrIsCallAccountingRequired", "$(var(accentries){s.select,10,|})", "$(var(accentries){s.select,12,|})")) {
xlog("L_ERR", "JS Call of ksrIsCallAccountingRequired route failed.\n");
}
```
And our JS code containing sqlops looks like this:
```
extension = '1234567e0';
mastersipid = '1234567';
KSR.sqlops.sql_query(
"dbconn",
`SELECT username, grp FROM grp WHERE username IN ('${mastersipid}', '${extension}') AND grp = 'ourGroupName'`,
user
);
```
For each call, this query is executed once. Depending on the traffic, you can see the private package memory starting to fill up quicker or slower.
#### Debugging Data
### Possible Solutions
We had a similar problem about two years ago with app_lua and getting entries from a hash table, which we solved by introducing a temporary variable for using in the hash table index instead of strings. We tried doing the same thing in our current setup:
```
KSR.pv.sets("$var(extensionForQuery)", extension);
KSR.pv.sets("$var(masterSipidForQuery)", masterSipid);
KSR.sqlops.sql_query(
"dbconn",
"SELECT username, grp FROM grp WHERE username IN ('$var(masterSipidForQuery)', '$var(extensionForQuery)') AND grp = 'ourGroupName'",
user
);
```
However, Kamailio doesn't replace the variables in the query string. Although the documentation of the sqlops module says, it supports pseudovars in the query string. We even tried putting the whole query into a variable, but ended up with a sqlops error.
### Additional Information
```
ersion: kamailio 5.1.4 (x86_64/linux)
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_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: unknown
compiled with gcc 4.7.2
```
* **Operating System**:
```
Debian Wheezy (yeah, I know... )
```
--
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/2032
Hello,
I am considering to do soon a new release out of branch 5.2,
respectively v5.2.4. I am aiming for August 12 or August 14, a matter of
how backporting is finished, given that next week some devs travel to
ClueCon.
As usual, if you are aware of issues not reported yet on bug tracker or
fixes not yet backported to branch 5.2, act during the next days to have
enough time to approach them.
Cheers,
Daniel
--
Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
Module: kamailio
Branch: master
Commit: 6542a638bee90afdbfe63b59d9d7f1d23b0406aa
URL: https://github.com/kamailio/kamailio/commit/6542a638bee90afdbfe63b59d9d7f1d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-08-13T16:07:05+02:00
rr: docs - note about use of record_route() for requests within dialog
- it has to be used after loose_route() for a proper detection of
request direction
---
Modified: src/modules/rr/doc/rr_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/6542a638bee90afdbfe63b59d9d7f1d…
Patch: https://github.com/kamailio/kamailio/commit/6542a638bee90afdbfe63b59d9d7f1d…
---
diff --git a/src/modules/rr/doc/rr_admin.xml b/src/modules/rr/doc/rr_admin.xml
index 74e59abe82..362edd4f1f 100644
--- a/src/modules/rr/doc/rr_admin.xml
+++ b/src/modules/rr/doc/rr_admin.xml
@@ -397,8 +397,7 @@ loose_route();
</section>
<section id="rr.f.record_route">
- <title><function moreinfo="none">record_route()</function> and <function
- moreinfo="none">record_route(string)</function></title>
+ <title><function moreinfo="none">record_route([sparams])</function></title>
<para>The function adds a new Record-Route header field. The header
field will be inserted in the message before any other Record-Route
@@ -414,6 +413,10 @@ loose_route();
request and generate and add a flow-token as the username part of the
Record-Route-URI.</para>
+ <para>Note: if append From-tag is enabled and the function is used for requests
+ within dialog, it must be executed after loose_route() in order to detect
+ properly the direction.</para>
+
<para>This function can be used from REQUEST_ROUTE, BRANCH_ROUTE and
FAILURE_ROUTE.</para>
Module: kamailio
Branch: master
Commit: 8546983de13bba7ed7a84a88ed91027e4291a1bc
URL: https://github.com/kamailio/kamailio/commit/8546983de13bba7ed7a84a88ed91027…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2019-08-13T10:16:43+02:00
modules: readme files regenerated - registrar ... [skip ci]
---
Modified: src/modules/registrar/README
---
Diff: https://github.com/kamailio/kamailio/commit/8546983de13bba7ed7a84a88ed91027…
Patch: https://github.com/kamailio/kamailio/commit/8546983de13bba7ed7a84a88ed91027…
---
diff --git a/src/modules/registrar/README b/src/modules/registrar/README
index d55fc5a7c9..e4516756e6 100644
--- a/src/modules/registrar/README
+++ b/src/modules/registrar/README
@@ -1070,7 +1070,7 @@ add_sock_hdr("Sock-Info");
* ruid - The record unique ID for a a specific contact to be removed.
It can contain pseudo-variables that are evaluated at runtime.
- This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ This function can be used from ANY_ROUTE.
Return values:
* 0 - Successfully deleted contact(s)
Module: kamailio
Branch: master
Commit: 23a5b8d9baf40a416401017324ceb01e7d769494
URL: https://github.com/kamailio/kamailio/commit/23a5b8d9baf40a416401017324ceb01…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-08-13T10:03:32+02:00
registrar: updated docs for unregister()
- function is allowed to be used in any route
---
Modified: src/modules/registrar/doc/registrar_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/23a5b8d9baf40a416401017324ceb01…
Patch: https://github.com/kamailio/kamailio/commit/23a5b8d9baf40a416401017324ceb01…
---
diff --git a/src/modules/registrar/doc/registrar_admin.xml b/src/modules/registrar/doc/registrar_admin.xml
index 32752eac89..67e13e09e3 100644
--- a/src/modules/registrar/doc/registrar_admin.xml
+++ b/src/modules/registrar/doc/registrar_admin.xml
@@ -1400,7 +1400,7 @@ add_sock_hdr("Sock-Info");
</listitem>
</itemizedlist>
<para>
- This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+ This function can be used from ANY_ROUTE.
</para>
<para>
Return values: