tarantool / queue

Create task queues, add and take jobs, monitor failed tasks
Other
237 stars 52 forks source link

utubettl: take doesn't account for state.DELAYED #73

Closed aleclarson closed 6 years ago

aleclarson commented 6 years ago

The :take method of utubettl does :pairs(state.READY, {iterator = 'GE'}), which perhaps unexpectedly matches tasks with state.DELAYED because apparently '~' >= 'r' == true.

But it doesn't look like utubettl:take accounts for that scenario:

https://github.com/tarantool/queue/blob/593c9f6f949c84865bcd383d542876ebbc93520a/queue/abstract/driver/utubettl.lua#L274-L291

We'll need a t[2] == state.DELAYED if statement wrapped around everything else, I think.

aleclarson commented 6 years ago

It works fine if you assume a DELAYED task will never come before a READY task. But what if you put a task with a small delay in the queue after putting another task with a large delay? Of course, the READY task will need to wait for the DELAYED task to finish.

aleclarson commented 6 years ago

@nekufa clarified to me how index:pairs works, so I'll close this now.

I opened an issue for the clarification to be added to the docs: https://github.com/tarantool/doc/issues/401