[sr-dev] [kamailio/kamailio] db_cluster module initialization problem - linked perhaps to change in srdb1 lib (#2385)

Andrew Pogrebennyk notifications at github.com
Thu Jul 2 10:19:45 CEST 2020


@miconda there was a copy&paste error here in my description
complete configuration looks like this:
```
# ----- db_cluster params ------
modparam("db_cluster", "connection", DB_URL_REDIS_READ)
modparam("db_cluster", "connection", DB_URL_REDIS_WRITE)
modparam("db_cluster", "cluster", "cluster1=>c1=9r0p;c2=0r9p")
```
So the configuration looks complete according to Readme. Still the debug prints i added revealed the len mismatch.
I have workarounded it in db_cluster module by recalculating the len in db_cluster_init. Here is the patch including the change and debug prints:
```
diff --git a/src/modules/db_cluster/dbcl_api.c b/src/modules/db_cluster/dbcl_api.c
index 111abcca2..b1ddcd9fc 100644
--- a/src/modules/db_cluster/dbcl_api.c
+++ b/src/modules/db_cluster/dbcl_api.c
@@ -264,27 +264,27 @@ db1_con_t* db_cluster_init(const str* _dburl)
        dbcl_cls_t *cls=NULL;
        str name;
 
-       LM_DBG("initializing with cluster [%.*s]\n", _dburl->len, _dburl->s);
+       LM_DBG("initializing with cluster [%.*s] len %d\n", _dburl->len, _dburl->s, _dburl->len);
        if(_dburl->len<10 || strncmp(_dburl->s, "cluster://", 10)!=0)
        {
-               LM_ERR("invlaid url for cluster module [%.*s]\n",
+               LM_ERR("invalid url for cluster module [%.*s]\n",
                                _dburl->len, _dburl->s);
                return NULL;
        }
        name.s = _dburl->s + 10;
-       name.len = _dburl->len - 10;
+       name.len = strlen(_dburl->s) - 10;
        trim(&name);
        cls = dbcl_get_cluster(&name);
        if(cls==NULL)
        {
                LM_ERR("cluster not found [%.*s]\n",
-                               _dburl->len, _dburl->s);
+                               name.len, name.s);
                return NULL;
        }
        if(dbcl_init_dbf(cls)<0)
        {
                LM_ERR("cluster [%.*s] - unable to bind to DB engines\n",
-                               _dburl->len, _dburl->s);
+                               name.len, name.s);
                return NULL;
        }
        dbcl_init_connections(cls);
```
I will re-test it against the latest master and report if I still need the patch.
But was thinking perhaps that the root cause is some changes in srdb1 lib.

-- 
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/2385#issuecomment-652861640
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200702/666b259a/attachment.html>


More information about the sr-dev mailing list