tarantool / queue

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

O(n^2) complexity in fifottl:take() #63

Closed rtsisyk closed 5 years ago

rtsisyk commented 6 years ago

take() degrades to O(N^2) complexity where N is the number of expired tasks:

https://github.com/tarantool/queue/blob/3adda75efab42c8bf437cb554c81d269cfe1b27e/queue/abstract/driver/fifottl.lua#L265-L275

Affects Cloud.

kostja commented 6 years ago

I have received numerous complains about this, without exact trace to the root cause.

Let's fix asap.

-- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.org - www.twitter.com/kostja_osipov

RunsFor commented 5 years ago

I reproduced it under following conditions:

I put my laptop into sleep mode while it was about 50k tuples in fifottl tube and 10 fibers were constantly taking tasks from it from another instance over a net box connection.

I woke up laptop after ttl was already expired for all tasks and noticed that: