In the "ttl tasks" loop of the fifottl and utubettl driver fibers the loop variable shadows the state module:
|
for _, state in pairs(ttl_states) do |
|
task = self.space.index.watch:min{ state } |
|
if task ~= nil and task[i_status] == state then |
|
if now >= task[i_next_event] then |
|
task = self:delete(task[i_id]):transform(2, 1, state.DONE) |
|
self:on_task_change(task, 'ttl') |
|
for _, state in pairs(ttl_states) do |
|
task = self.space.index.watch:min{ state } |
|
if task ~= nil and task[i_status] == state then |
|
if now >= task[i_next_event] then |
|
task = self:delete(task[i_id]):transform(2, 1, state.DONE) |
|
self:on_task_change(task, 'ttl') |
Inside the loop state is a status string, so state.DONE indexes a string and evaluates to nil. transform(2, 1, nil) then writes NULL into the status field instead of DONE:
tarantool> box.tuple.new{10, 'r', 111}:transform(2, 1, nil)
---
- [10, null, 111]
...
So the task passed to the user's on_task_change callback with the ttl event is malformed. Internal bookkeeping is unaffected: the READY/TAKEN branches in abstract.lua are skipped for a deleted task anyway and the statistics are still counted.
Steps to reproduce
local tube = queue.create_tube('t', 'fifottl', {ttl = 0.1,
on_task_change = function(task, event)
if event == 'ttl' then require('log').info('status: %s', tostring(task[2])) end
end})
tube:put('expired')
Actual behavior
status: cdata<void *>: NULL
Expected behavior
status: - (state.DONE)
Renaming the loop variable is enough.
In the "ttl tasks" loop of the
fifottlandutubettldriver fibers the loop variable shadows thestatemodule:queue/queue/abstract/driver/fifottl.lua
Lines 112 to 117 in 03cece7
queue/queue/abstract/driver/utubettl.lua
Lines 239 to 244 in 03cece7
Inside the loop
stateis a status string, sostate.DONEindexes a string and evaluates tonil.transform(2, 1, nil)then writes NULL into the status field instead ofDONE:So the task passed to the user's
on_task_changecallback with thettlevent is malformed. Internal bookkeeping is unaffected: the READY/TAKEN branches inabstract.luaare skipped for a deleted task anyway and the statistics are still counted.Steps to reproduce
Actual behavior
status: cdata<void *>: NULLExpected behavior
status: -(state.DONE)Renaming the loop variable is enough.