Skip to content

Commit 33721d0

Browse files
committed
Release all taken tasks on start
If some tasks have been taken and don't released before shutdown of the tarantool instance (for example: tarantool instance has been killed) such task go to 'hung' state (noone can take the task now). So, we must release all taken tasks on start of the queue module. Fixes #66
1 parent a812c10 commit 33721d0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

queue/abstract.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,20 @@ function method.start()
511511
})
512512
end
513513

514-
_queue:pairs():each(recreate_tube)
514+
for _, tube_tuple in _queue:pairs() do
515+
local space_name = tube_tuple[3]
516+
tube = recreate_tube(tube_tuple)
517+
local space = box.space[space_name]
518+
for _, task_tuple in space:pairs() do
519+
-- Release all taken tasks on start
520+
-- See https://github.com/tarantool/queue/issues/66
521+
-- for more information
522+
local tid, task_state = task_tuple[1], task_tuple[2]
523+
if task_state == state.TAKEN then
524+
tube.raw:release(tid)
525+
end
526+
end
527+
end
515528

516529
session.on_disconnect(queue._on_consumer_disconnect)
517530
return queue

0 commit comments

Comments
 (0)