Summary:ASTERISK-19368: Queue penalty only work when QUEUE_MIN_PENALTY == QUEUE_MAX_PENALTY
Reporter:Avraam David (adavid)Labels:
Date Opened:2012-02-15 09:00:47.000-0600Date Closed:2014-03-04 04:41:12.000-0600
Versions: Frequency of
is related toASTERISK-20862 Asterisk min and max member penalties not honored when set with 0
is related toASTERISK-21879 app_queue's autofill=yes effectively fails to deliver all calls when those calls are preceded by a call with a min/max penalty that can't be delivered
Environment:Attachments:( 0) d1
Description:I have a queue with two groups of members with different penalty, Should work with queueruls.conf or autofill = yes.

If QUEUE_MIN_PENALTY is not equal to QUEUE_MAX_PENALTY, member on second group can't received  calls.

exten => s,n,Set(QUEUE_MIN_PENALTY=1)
exten => s,n,Set(QUEUE_MAX_PENALTY=2)


penaltychange => 10,1,0
penaltychange => 21,2,0

Not works.

work only

exten => s,n,Set(QUEUE_MIN_PENALTY=1)
exten => s,n,Set(QUEUE_MAX_PENALTY=1)


penaltychange => 10,1,1
penaltychange => 20,2,2

also if not defined min penalty on queuerules.conf penaltychange like
penaltychange => 20,2

not works, only if set same parameters on penaltychange line MIN and MAX
penaltychange => 20,2,2
Comments:By: Matt Jordan (mjordan) 2012-02-20 11:12:05.918-0600

We require a complete debug log to help triage the issue. This document will provide instructions on how to collect debugging logs from an Asterisk machine for the purpose of helping bug marshals troubleshoot an issue: https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information

By: Avraam David (adavid) 2012-02-20 17:19:49.205-0600

asterisk -rx"queue show 989898"
989898 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:7, SL:0.0% within 60s
     Local/251@from-queue/n with penalty 1 (dynamic) (Not in use) has taken no calls yet
     Local/206@from-queue/n with penalty 2 (dynamic) (Not in use) has taken no calls yet
  No Callers

[root@ysb ~]# asterisk -rx"queue show rules ruletest"
Rule: ruletest
       After 20 seconds, adjust QUEUE_MAX_PENALTY to 2 and adjust QUEUE_MIN_PENALTY to 0

By: Avraam David (adavid) 2012-02-20 17:21:41.042-0600

attach log file

By: Jesus Mogollon (gocho2012) 2012-03-09 16:08:02.604-0600

I was able to replicate this problem on the 1.6.0.X branch as well. It would only work with QUEUE_MAX_PENALTY and QUEUE_MIN_PENALTY being equal. As it is, we are limited to rules that separate agents into mutually exclusive groups.  

By: Robert Verspuy (exarv) 2012-12-04 09:13:12.751-0600

The problem lies in calc_metric in apps/app_queue.c.

Example: We have 3 phones: agent 201 (penalty 1), 202 (penalty 2) and 203 (penalty 3).
Rules: After 15 seconds, raise penalty_max to 2, after 30 seconds raise penalty_max to 3.

What do we want:
when a call comes in, agent 201 must ring for 15 seconds. Then agent 201 and agent 202 must ring, and 15 seconds later, all three phones must ring.

Strategy is ringall, we do not want autopause.

When one call comes in, agent 201 ring, everything ok. Then the penalty max is raised to 2. This should make agent 201 and 202 ring, because we have a min_penalty of 1 and a max_penalty of 2. But only agent 201 rings.

In calc_metrics, when using strategy ringall a tmp_metric is calculated based on member penalty * 1000000 * usepenalty (=1 in our case).

When debugging I saw that agent 201 and agent 202 must be ringing, but because of the tmp_metric is different for both agents, only agent 201 rings (lowest metric).

My workaround for our case is to remove the line 'tmp->metric = mem->penalty * 1000000 * usepenalty' in that function.
And then all agents between the min and max penalty values, are all ringing together, and not based on their own penalty values.

By: Paul Belanger (pabelanger) 2013-01-18 11:23:44.041-0600

Just ran into this issue today, going to see what I can add to the conversation.

By: Joel Vandal (joel_vandal) 2013-06-03 10:24:40.748-0500

Also have the same issue where call to agent work only if we Min/Max penalty to same value (ex. 30 == 30) on queuerules.conf.

Using Asterisk 11.

By: Joel Vandal (joel_vandal) 2013-08-05 09:18:52.048-0500

Anyone else reproduce this issue ?

By: Toomas Vahtra (zpotoloom) 2013-10-14 08:41:38.241-0500

Same behavior with

I would suggest the following change in app_queue.c function ring_one to replace line
{{if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) {}}
{{if (cur->stillgoing && !cur->chan && cur->metric >= qe->min_penalty * 1000000 && cur->metric <= qe->max_penalty * 1000000 ) {}}

then it will consider QUEUE_MIN_PENALTY and QUEUE_MAX_PENALTY values correctly.
Also when not defining penalty values with dialplan, then QUEUE_MIN_PENALTY and QUEUE_MAX_PENALTY are both 0 and this change evaluates to true cause cur->metric will be 0 also and will not affect queues without penalty.

By: Darren Philips (darren76) 2014-01-16 19:35:00.925-0600

I can confirm this is the same in 11.6 :(

By: Avraam David (adavid) 2014-03-04 04:40:53.349-0600

fix in version 11.8.0.

By: Avraam David (adavid) 2014-03-04 04:41:12.665-0600

in version 11.8.0