### Description
I want to start Kamailio with this config ``` loadmodule "db_redis.so" loadmodule "permissions.so" loadmodule "rtpengine.so" #loadmodule "permissions.so"
modparam("db_redis", "keys", "address=entry:id") modparam("permissions", "db_url", "redis://127.0.0.1:6379/1"); modparam("rtpengine", "db_url", "redis://127.0.0.1:6379/1")
listen = udp:eth0:5060 ``` When start Kamailio I get this error ```sh [root@ip-172-22-6-111 kamailio]# kamailio -DD -E Listening on udp: 172.22.6.111:5060 Aliases: udp: ip-172-22-6-111.us-west-1.compute.internal:5060
0(54483) ERROR: db_redis [redis_dbase.c:951]: db_redis_scan_query_keys(): Failed to allocate memory for match pattern 0(54483) ERROR: db_redis [redis_dbase.c:1471]: db_redis_perform_query(): failed to scan query keys 0(54483) ERROR: db_redis [redis_dbase.c:1607]: db_redis_perform_query(): failed to perform the query 0(54483) ERROR: db_redis [redis_dbase.c:2397]: db_redis_query(): failed to do the query 0(54483) ERROR: rtpengine [rtpengine_db.c:90]: rtpp_load_db(): error while running db query 0(54483) ERROR: rtpengine [rtpengine.c:1628]: mod_init(): error while loading rtpengine instances from database 0(54483) ERROR: <core> [core/sr_module.c:871]: init_mod(): Error while initializing module rtpengine (/usr/lib64/kamailio/modules/rtpengine.so) ERROR: error while initializing modules 0(54483) ERROR: rtpengine [rtpengine_hash.c:134]: rtpengine_hash_table_destroy(): NULL rtpengine_hash_table ```
### Troubleshooting When swap order load of `rtpengine` and `permissions`, then Kmailio will start properly
#### Reproduction Install redis server on hosts and start kamailio with config above.
#### Debugging Data None
#### Log Messages
``` 0(54469) DEBUG: db_redis [redis_connection.c:119]: db_redis_connect(): connecting to redis at 127.0.0.1:6379 0(54469) DEBUG: db_redis [redis_connection.c:172]: db_redis_connect(): connection opened to redis://127.0.0.1:6379/1 0(54469) DEBUG: db_redis [redis_connection.c:197]: db_redis_connect(): connection opened to redis://127.0.0.1:6379/1 0(54469) DEBUG: db_redis [redis_connection.c:258]: db_redis_new_connection(): connection opened to redis://127.0.0.1:6379/1 0(54469) DEBUG: db_redis [redis_dbase.c:2319]: db_redis_query(): querying prefix (table) 'version' 0(54469) DEBUG: db_redis [redis_dbase.c:188]: db_redis_return_version(): get table version 0(54469) DEBUG: <core> [db_res.c:119]: db_new_result(): allocate 56 bytes for result set at 0x7fa9e646d228 0(54469) DEBUG: <core> [db_res.c:188]: db_allocate_rows(): allocate 16 bytes for rows at 0x7fa9e646d2c8 0(54469) DEBUG: <core> [db_res.c:156]: db_allocate_columns(): allocate 8 bytes for result names at 0x7fa9e646d340 0(54469) DEBUG: <core> [db_res.c:167]: db_allocate_columns(): allocate 4 bytes for result types at 0x7fa9e646d3b0 0(54469) DEBUG: <core> [db_row.c:117]: db_allocate_row(): allocate 32 bytes for row values at 0x7fa9e646d420 0(54469) DEBUG: db_redis [redis_dbase.c:228]: db_redis_return_version(): returning short-cut table version 1 for table 'rtpengine' 0(54469) DEBUG: db_redis [redis_dbase.c:2826]: db_redis_free_result(): perform redis free result 0(54469) DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 1 columns 0(54469) DEBUG: <core> [db_res.c:96]: db_free_columns(): freeing result names at 0x7fa9e646d340 0(54469) DEBUG: <core> [db_res.c:101]: db_free_columns(): freeing result types at 0x7fa9e646d3b0 0(54469) DEBUG: <core> [db_res.c:52]: db_free_rows(): freeing 1 rows 0(54469) DEBUG: <core> [db_row.c:95]: db_free_row(): freeing row values at 0x7fa9e646d420 0(54469) DEBUG: <core> [db_res.c:60]: db_free_rows(): freeing rows at 0x7fa9e646d2c8 0(54469) DEBUG: <core> [db_res.c:138]: db_free_result(): freeing result set at 0x7fa9e646d228 0(54469) DEBUG: db_redis [redis_dbase.c:2319]: db_redis_query(): querying prefix (table) 'rtpengine' 0(54469) DEBUG: db_redis [redis_dbase.c:2370]: db_redis_query(): no columns given to build query keys, falling back to full table scan 0(54469) DEBUG: <core> [db_res.c:119]: db_new_result(): allocate 56 bytes for result set at 0x7fa9e646d298 0(54469) DEBUG: <core> [db_res.c:156]: db_allocate_columns(): allocate 32 bytes for result names at 0x7fa9e646d338 0(54469) DEBUG: <core> [db_res.c:167]: db_allocate_columns(): allocate 16 bytes for result types at 0x7fa9e646d3c0 0(54469) DEBUG: db_redis [redis_dbase.c:1466]: db_redis_perform_query(): loading full table: 'rtpengine 0(54469) ERROR: db_redis [redis_dbase.c:951]: db_redis_scan_query_keys(): Failed to allocate memory for match pattern 0(54469) ERROR: db_redis [redis_dbase.c:1471]: db_redis_perform_query(): failed to scan query keys 0(54469) ERROR: db_redis [redis_dbase.c:1607]: db_redis_perform_query(): failed to perform the query 0(54469) DEBUG: db_redis [redis_dbase.c:2826]: db_redis_free_result(): perform redis free result 0(54469) DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 4 columns 0(54469) DEBUG: <core> [db_res.c:96]: db_free_columns(): freeing result names at 0x7fa9e646d338 0(54469) DEBUG: <core> [db_res.c:101]: db_free_columns(): freeing result types at 0x7fa9e646d3c0 0(54469) DEBUG: <core> [db_res.c:138]: db_free_result(): freeing result set at 0x7fa9e646d298 0(54469) ERROR: db_redis [redis_dbase.c:2397]: db_redis_query(): failed to do the query 0(54469) ERROR: rtpengine [rtpengine_db.c:90]: rtpp_load_db(): error while running db query 0(54469) DEBUG: db_redis [redis_dbase.c:66]: db_redis_close(): closing redis db connection 0(54469) DEBUG: <core> [db_pool.c:100]: pool_remove(): removing connection from the pool 0(54469) DEBUG: db_redis [redis_connection.c:279]: db_redis_free_connection(): freeing db_redis connection 0(54469) ERROR: rtpengine [rtpengine.c:1628]: mod_init(): error while loading rtpengine instances from database 0(54469) ERROR: <core> [core/sr_module.c:871]: init_mod(): Error while initializing module rtpengine (/usr/lib64/kamailio/modules/rtpengine.so) ERROR: error while initializing modules 0(54469) ERROR: rtpengine [rtpengine_hash.c:134]: rtpengine_hash_table_destroy(): NULL rtpengine_hash_table 0(54469) DEBUG: rtpengine [rtpengine.c:2056]: mod_destroy(): rtpengine_hash_table_destroy() success! 0(54469) DEBUG: db_redis [db_redis_mod.c:114]: mod_destroy(): module destroying 0(54469) INFO: <core> [core/sctp_core.c:53]: sctp_core_destroy(): SCTP API not initialized 0(54469) DEBUG: <core> [core/mem/shm.c:288]: shm_destroy_manager(): destroying memory manager: q_malloc 0(54469) DEBUG: <core> [core/mem/q_malloc.c:1185]: qm_shm_lock_destroy(): destroying the shared memory lock 0(54469) DEBUG: <core> [core/mem/pkg.c:97]: pkg_destroy_manager(): destroying memory manager: q_malloc ```
#### SIP Traffic None
### Possible Solutions Not know
### Additional Information * **Kamailio Version** - output of `kamailio -v` ``` version: kamailio 5.5.0-dev1 (x86_64/linux) 57e63d flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, 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, TLS_PTHREAD_MUTEX_SHARED 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: 57e63d compiled on 04:01:10 Aug 11 2020 with gcc 8.3.1 ```
* **Operating System**: ``` NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8" ```
when used config with `rtpengine` and `dispatcher` is not mater order load. Kamailio always fail load.
``` loadmodule "db_redis.so" loadmodule "rtpengine.so" loadmodule "dispatcher.so"
modparam("db_redis", "keys", "address=entry:id") modparam("rtpengine", "db_url", "redis://127.0.0.1:6379/1") modparam("dispatcher", "db_url", "redis://127.0.0.1:6379/1")
listen = udp:eth0:5060 ```
Do you have a lot of records in the tables? Have you tried with more pkg memory (-M cli parameter)?
`redis` database is clean, just started the first time. I tried change -M and -m options, it does not matter.
I found the issue raised when Kamailio try to load the whole table. ``` 0(54469) DEBUG: db_redis [redis_dbase.c:2319]: db_redis_query(): querying prefix (table) 'rtpengine' 0(54469) DEBUG: db_redis [redis_dbase.c:2370]: db_redis_query(): no columns given to build query keys, falling back to full table scan ``` If I specify a table key, then Kamailio start properly.
Maybe @rfuchs has an opinion on this one, as he develops rtpengine module, but did also commits to db_redis.
First of all, if you have two modules both using the same Redis DB, you should make them use different DB numbers.
And then, since Redis is key-value only and doesn't have a DB schema, you need to specify the schema for each DB you want to use through the `keys` modparam to db_redis. Have you done this?
When I added `key` for both tables, then the issue resolved.
This can be closed then?
if such behavior is expected, then yes, we can.
Closed #2441.