[OpenSIPS-Devel] [ opensips-Bugs-3604147 ] load_balance in failure_route

SourceForge.net noreply at sourceforge.net
Sat Feb 16 23:32:06 CET 2013


Bugs item #3604147, was opened at 2013-02-11 11:12
Message generated for change (Comment added) made by sethschultz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=3604147&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: 1.9.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Seth Schultz (sethschultz)
Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
Summary: load_balance in failure_route

Initial Comment:
Hello,

I call load_balance in my failure_route for sip_codes "(408)|[56][0-9]{2}".  This works, however, once all of the destinations have been exhausted, it continually tries to load balance the call to the last address, instead of returning false.  Please see the snippet below.

failure_route[1]
{
...
if (t_was_cancelled())
{
    exit;
}

if (is_method("INVITE") && $tt == NULL && t_check_status("(403)|(404)|(408)|([56][0-9]{2})"))
{
if(load_balance("1", "pstn", "1"))
{
...  #this code gets continually called with the last address in the pool instead of hitting the else condition below
}
else
{
    send_reply("$rs","$rr");
    exit;
}
}
...
}

----------------------------------------------------------------------

>Comment By: Seth Schultz (sethschultz)
Date: 2013-02-16 14:32

Message:
Bogdan,

My script is nearly identical to yours (I am re-arming the failure route
and then relaying).  I do, however, set the $rd variable after a successful
load_balance call, I am not sure if this makes a difference.  Notice that
in my output, the used set never grows to be bigger than 1.

Here is the output I get for the load_balance group which contains a set of
3 addresses all of which have resource pstn=100:

sip:aaa.aaa.aaa.aaa:5060
sip:bbb.bbb.bbb.bbb:5060
sip:ccc.ccc.ccc.ccc:5060

Log Output:

DBG:load_balancer:do_load_balance: found requested (0) resource pstn
DBG:load_balancer:do_load_balance: destination <sip:ccc.ccc.ccc.ccc:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: destination <sip:bbb.bbb.bbb.bbb:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: destination <sip:aaa.aaa.aaa.aaa:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: winning destination
<sip:bbb.bbb.bbb.bbb:5060> selected for LB set with free=100

...

DBG:load_balancer:do_load_balance: sequential call of LB - previous
selected dst is 7
DBG:load_balancer:do_load_balance: found requested (0) resource pstn
DBG:load_balancer:do_load_balance: skipping destination
<sip:bbb.bbb.bbb.bbb:5060> (used=1 , disabled=0)
DBG:load_balancer:do_load_balance: destination <sip:aaa.aaa.aaa.aaa:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: destination <sip:ccc.ccc.ccc.ccc:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: winning destination
<sip:ccc.ccc.ccc.ccc:5060> selected for LB set with free=100

...

DBG:load_balancer:do_load_balance: sequential call of LB - previous
selected dst is 15
DBG:load_balancer:do_load_balance: found requested (0) resource pstn
DBG:load_balancer:do_load_balance: skipping destination
<sip:bbb.bbb.bbb.bbb:5060> (used=1 , disabled=0)
DBG:load_balancer:do_load_balance: destination <sip:ccc.ccc.ccc.ccc:5060>
selected for LB set with free=99 (max=99)
DBG:load_balancer:do_load_balance: destination <sip:aaa.aaa.aaa.aaa:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: winning destination
<sip:aaa.aaa.aaa.aaa:5060> selected for LB set with free=100

...

DBG:load_balancer:do_load_balance: found requested (0) resource pstn
DBG:load_balancer:do_load_balance: sequential call of LB - previous
selected dst is 19
DBG:load_balancer:do_load_balance: skipping destination
<sip:bbb.bbb.bbb.bbb:5060> (used=1 , disabled=0)
DBG:load_balancer:do_load_balance: destination <sip:ccc.ccc.ccc.ccc:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: destination <sip:aaa.aaa.aaa.aaa:5060>
selected for LB set with free=99 (max=100)
DBG:load_balancer:do_load_balance: winning destination
<sip:ccc.ccc.ccc.ccc:5060> selected for LB set with free=100

...

DBG:load_balancer:do_load_balance: sequential call of LB - previous
selected dst is 15
DBG:load_balancer:do_load_balance: found requested (0) resource pstn
DBG:load_balancer:do_load_balance: destination <sip:ccc.ccc.ccc.ccc:5060>
selected for LB set with free=99 (max=99)
DBG:load_balancer:do_load_balance: skipping destination
<sip:bbb.bbb.bbb.bbb:5060> (used=1 , disabled=0)
DBG:load_balancer:do_load_balance: destination <sip:aaa.aaa.aaa.aaa:5060>
selected for LB set with free=100 (max=100)
DBG:load_balancer:do_load_balance: winning destination
<sip:aaa.aaa.aaa.aaa:5060> selected for LB set with free=100


Thanks,
Seth


----------------------------------------------------------------------

Comment By: Seth Schultz (sethschultz)
Date: 2013-02-16 10:51

Message:
I will apply the patch, retest, and then post the output here.  Standby.

Thanks,
Seth

----------------------------------------------------------------------

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2013-02-16 01:30

Message:
Hi Seth,

Tested with trunk version (and 1.9) with this script:

failure_route[lb]
{
	if (load_balance("1","pstn","1") ) {
		xlog("L_DEBUG", "\n===DESTINATION IS $du===\n");
		t_on_failure("lb");
		t_relay();
	}
}


route {

	load_balance("1","pstn","1");
	xlog("L_DEBUG", "\n===DESTINATION IS $du===\n");
	t_on_failure("lb");

	t_relay();
	exit;
}


I used 2 destinations in LB  and it stopped after the second failure . See
here the logs :

Feb 16 11:28:52 [24870] DBG:load_balancer:do_load_balance: found requested
(0) resource pstn
Feb 16 11:28:52 [24870] DBG:load_balancer:do_load_balance: destination
<sip:127.0.0.10> selected for LB set with free=100 (max=100)
Feb 16 11:28:52 [24870] DBG:load_balancer:do_load_balance: destination
<sip:127.0.0.15> selected for LB set with free=100 (max=100)
Feb 16 11:28:52 [24870] DBG:load_balancer:do_load_balance: winning
destination <sip:127.0.0.10> selected for LB set with free=100
.....
Feb 16 11:28:57 [24877] DBG:load_balancer:do_load_balance: found requested
(0) resource pstn
Feb 16 11:28:57 [24877] DBG:load_balancer:do_load_balance: sequential call
of LB - previous selected dst is 1
Feb 16 11:28:57 [24877] DBG:load_balancer:do_load_balance: skipping
destination <sip:127.0.0.10> (used=1 , disabled=0)
Feb 16 11:28:57 [24877] DBG:load_balancer:do_load_balance: destination
<sip:127.0.0.15> selected for LB set with free=100 (max=100)
Feb 16 11:28:57 [24877] DBG:load_balancer:do_load_balance: winning
destination <sip:127.0.0.15> selected for LB set with free=100
.....
Feb 16 11:29:03 [24877] DBG:load_balancer:do_load_balance: found requested
(0) resource pstn
Feb 16 11:29:03 [24877] DBG:load_balancer:do_load_balance: sequential call
of LB - previous selected dst is 2
Feb 16 11:29:03 [24877] DBG:load_balancer:do_load_balance: skipping
destination <sip:127.0.0.10> (used=1 , disabled=0)
Feb 16 11:29:03 [24877] DBG:load_balancer:do_load_balance: skipping
destination <sip:127.0.0.15> (used=1 , disabled=0)
Feb 16 11:29:03 [24877] DBG:load_balancer:do_load_balance: no destination
found


Please consider the attached patch for more debugs - run with it and post
the logs generated by the LB module

Regards,
Bogdan

----------------------------------------------------------------------

Comment By: Seth Schultz (sethschultz)
Date: 2013-02-11 11:35

Message:
I should note that I have tried it with both the 0 and the 1 algorithm. 
Both of them fail in the same way.

Thanks,
Seth

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=3604147&group_id=232389



More information about the Devel mailing list