[Home]

Summary:ASTERISK-18480: Linear queue orders real time members alphabetically by their interface.
Reporter:Steven Wheeler (swheeler)Labels:
Date Opened:2011-09-08 10:44:49Date Closed:2011-09-08 11:53:10
Priority:MajorRegression?
Status:Closed/CompleteComponents:Applications/app_queue Core/Configuration Resources/res_config_odbc
Versions:1.6.2.15 1.8.5.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:
Description:When using real time queues & queue members with res_config_odbc we have noticed that Asterisk does not respect the order of members in linear queues.  It instead orders the members alphabetically by the value of their 'interface' column in the database, but it should be sorting the members by their 'uniqueid' column.

I believe that I have narrowed down the source of the problem in app_queue.c in the method load_realtime_queue() members are loaded with a call to:
app_queue.c:2350 ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, SENTINEL)

The problem with this call is that res_config_odbc's realtime_multi_odbc is called and this method uses the first column in the list as the 'order by' column:
res_config_odbc.c:372 snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s", initfield);

I have tried modifying the call in app_queue.c so that the uniqueid column was the first in the list, but that caused even more problems because the queue then tried to use the member's uniqueid as their interface.  I think this should be a pretty easy fix for someone who knows the Asterisk source better than I.  Any help you can offer would be greatly appreciated.
Comments:By: Tilghman Lesher (tilghman) 2011-09-08 11:52:44.838-0500

This is not a problem with Asterisk.  There is no implicit or explicit determination that the uniqueid orders the queue members.  It is a string field meant to ensure that each member has a unique key associated with it, for the purposes of easy updating.  There is no other purpose of the uniqueid field.

By: Steven Wheeler (swheeler) 2011-09-08 11:57:46.561-0500

So what method should we use for defining the order of members in a linear queue?

By: Tilghman Lesher (tilghman) 2011-09-09 15:00:51.007-0500

We don't specify that any particular order will be enforced, only that linear uses the order in which members are added to the queue.  Whomever wrote the "linear" model either didn't think about the realtime model or didn't care.