[sr-dev] git:master: db_cluster: new module for generic database clustering

Daniel-Constantin Mierla miconda at gmail.com
Mon Apr 9 11:46:04 CEST 2012


Hello,

I am just thinking of making the connection inactive, via a flag in 
shared memory, so the other processes will ignore it as well. Then, if 
the connection is active more than N seconds, try to use it again, and 
if fails, keep it inactive.

This will work for every kind of selecting policy, read or write 
operation. I hope to push the patch very soon. Your patch could be ok 
for serial selection, but then we would have to add different ones for 
round robin and parallel operations.

Cheers,
Daniel

On 4/7/12 4:59 PM, Juha Heinanen wrote:
> daniel,
>
> the patch below upgrades working connection if read operation on another
> connection with same priority has failed, i.e., next time the working
> connection will be tried before the failing one.
>
> is the patch ok with you?  if so, the same could be done on write
> operations.
>
> -- juha
>
> *** /usr/src/orig/sip-router/modules_k/db_cluster/dbcl_api.c	2012-03-28 18:26:21.000000000 +0300
> --- modules_k/db_cluster/dbcl_api.c	2012-04-07 17:51:28.000000000 +0300
> ***************
> *** 46,51 ****
> --- 46,52 ----
>    	int k;\
>    	db1_con_t  *dbh=NULL;\
>    	dbcl_cls_t *cls=NULL;\
> + 	dbcl_con_t *tmp;\
>    	cls = (dbcl_cls_t*)_h->tail;\
>    	ret = 0;\
>    	for(i=DBCL_PRIO_SIZE-1; i>0; i--)\
> ***************
> *** 58,68 ****
>    					if(cls->rlist[i].clist[j] != NULL&&  cls->rlist[i].clist[j]->flags!=0\
>    						&&  cls->rlist[i].clist[j]->dbh != NULL)\
>    					{\
> ! 						LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
>    								cls->name.len, cls->name.s, i, j);\
>    						dbh = cls->rlist[i].clist[j]->dbh;\
>    						ret = cls->rlist[i].clist[j]->dbf.command;\
>    						if (ret==0) {\
>    							cls->usedcon = cls->rlist[i].clist[j];\
>    							return 0;\
>    						}\
> --- 59,76 ----
>    					if(cls->rlist[i].clist[j] != NULL&&  cls->rlist[i].clist[j]->flags!=0\
>    						&&  cls->rlist[i].clist[j]->dbh != NULL)\
>    					{\
> ! 					        LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n", \
>    								cls->name.len, cls->name.s, i, j);\
>    						dbh = cls->rlist[i].clist[j]->dbh;\
>    						ret = cls->rlist[i].clist[j]->dbf.command;\
>    						if (ret==0) {\
> + 						        if (j>  0) {\
> + 							    LM_INFO("upgrading connection - cluster [%.*s] (%d/%d)\n", \
> + 								cls->name.len, cls->name.s, i, j);\
> + 							    tmp = cls->rlist[i].clist[j];\
> + 							    cls->rlist[i].clist[j] = cls->rlist[i].clist[j-1];\
> + 							    cls->rlist[i].clist[j-1] = tmp;\
> + 							}\
>    							cls->usedcon = cls->rlist[i].clist[j];\
>    							return 0;\
>    						}\
>
>

-- 
Daniel-Constantin Mierla
Kamailio Advanced Training, April 23-26, 2012, Berlin, Germany
http://www.asipto.com/index.php/kamailio-advanced-training/




More information about the sr-dev mailing list