Skip to content

Commit b17a38b

Browse files
committed
FIXUP: Release all taken tasks on start
* Verify tarantool version for stable iterators support. * Add more logs to give a user idea what is going on.
1 parent 840e5f4 commit b17a38b

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

queue/abstract.lua

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ queue.driver = {
6363
limfifottl = require('queue.abstract.driver.limfifottl')
6464
}
6565

66+
local function tube_release_all_tasks(tube)
67+
local prefix = ('queue: [tube "%s"] '):format(tube.name)
68+
69+
-- We lean on stable iterators in this function.
70+
-- https://github.com/tarantool/tarantool/issues/1796
71+
if not qc.check_version({1, 7, 5}) then
72+
log.error(prefix .. 'no stable iterator support: skip task releasing')
73+
log.error(prefix .. 'some tasks may stuck in taken state perpetually')
74+
log.error(prefix .. 'update tarantool to >= 1.7.5 or take the risk')
75+
end
76+
77+
log.info(prefix .. 'releasing all taken task (may take a while)')
78+
local released = 0
79+
for _, task in tube.raw:tasks_by_state(state.TAKEN) do
80+
tube.raw:release(task[1])
81+
released = released + 1
82+
end
83+
log.info(prefix .. ('released %d tasks'):format(released))
84+
end
85+
6686
-- tube methods
6787
local tube = {}
6888

@@ -512,14 +532,9 @@ function method.start()
512532
end
513533

514534
for _, tube_tuple in _queue:pairs() do
515-
local space_name = tube_tuple[3]
516-
tube = recreate_tube(tube_tuple)
517-
for _, task in tube.raw:tasks_by_state(state.TAKEN) do
518-
-- Release all taken tasks on start
519-
-- See https://github.com/tarantool/queue/issues/66
520-
-- for more information
521-
tube.raw:release(task[1])
522-
end
535+
local tube = recreate_tube(tube_tuple)
536+
-- gh-66: release all taken tasks on start
537+
tube_release_all_tasks(tube)
523538
end
524539

525540
session.on_disconnect(queue._on_consumer_disconnect)

0 commit comments

Comments
 (0)