Tip #1186: Race conditions with queue items

Today’s tip is from Marius “flow like a river” Lind. (And you can also become a tipster by sending your tip to jar@crmtipoftheday.com)

What happens when a race condition happens in a queue? Let’s say we have a bunch of customer service representatives who are working on cases in the same queue. The queue is sorted by priority and you should always pick the top case. Joel and Marius opens up the queue view at the same time, but Marius is a second faster than Joel to pick the top case. What happens now?

Well, one out of two things.

  1. Marius chose to pick but not remove the item from the queue.
    Joel picks the case, and since the queue item still exists the action taken by him simply resolves and the case is delegated to him.
  2. Marius chose to pick and remove the item from the queue.
    Joel is presented with the following error message
    clip_image002

So how do we deal with this?

For scenario 1, here’s a few options:

  • Accept that this might happen
  • Create a plugin which prevents someone from picking something that’s being worked on

For scenario 2:

  • Tell users about this, accept that it might happen

How to reduce the risk of this happening:

  • Make sure you teach your users to refresh the list view if it’s been open for a while
  • Distribute over several queues to prevent too many people working in the same queue
  • Or maybe you have a better idea, drop it into the comment.

Best regards, your friendly neighbourhood Viking!

(Facebook and Twitter cover photo by davide ragusa on Unsplash)

2 thoughts on “Tip #1186: Race conditions with queue items

  1. Michael Blackburn says:

    This is really annoying, why would a software company use an object and call it a “Queue” but have no “pop” item method??? It doesn’t seem like queues have any intrinsic order to them at all.

    • How else would you call it? When naming things like that the target are users not developers. We could also complain how we have “accounts” but no “transfer” method to move money from one account to another 😀

      If you want to “pop”, decide what order (e.g. FIFO or FILO), get the first queue item and use RemoveItem method. Two calls instead of one, not as convenient as “pop” but the queues are a shared construct so visibility of items could be different depending on who the user is.

Leave a Reply

Your email address will not be published. Required fields are marked *