#612 load_balance in failure_route

1.10.x
closed-fixed
modules (454)
5
2013-05-10
2013-02-11
No

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;
}
}
...
}

Discussion

  • Seth Schultz

    Seth Schultz - 2013-02-11

    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

     
  • Bogdan-Andrei Iancu

    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

     
  • Bogdan-Andrei Iancu

    • assigned_to: nobody --> bogdan_iancu
    • milestone: --> 1.9.x
     
  • Seth Schultz

    Seth Schultz - 2013-02-16

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

    Thanks,
    Seth

     
  • Seth Schultz

    Seth Schultz - 2013-02-16

    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

     
  • Bogdan-Andrei Iancu

    Hi Seth,

    Thanks to your help, I found and fix the bug - the marking of the used destination (during the failover) was bogus if the destination ID was higher than 8.

    SVN is updated trunk, 1.9, 1.8, 1.7 , so please remove the patch I sent, update from SVN and try again, it should work now.

    Regards,
    Bogdan

     
  • Bogdan-Andrei Iancu

    • status: open --> open-fixed
     
  • Bogdan-Andrei Iancu

    • status: open-fixed --> closed-fixed
     

Log in to post a comment.