From e2bd22d3dbb582e486f7c6aebc2aa929958dd630 Mon Sep 17 00:00:00 2001 From: Ilya Kosarev Date: Thu, 26 Sep 2019 14:02:16 +0300 Subject: [PATCH] fix fifottl_fiber_iteration error handling fifottl_fiber pcalls fifottl_fiber_iteration and then handles result. Returned error code comparison with box.error.READONLY was not done properly. Now it is fixed. Corresponding test case: buried task in dropped queue scenario is added. Closes #96 --- queue/abstract/driver/fifottl.lua | 2 +- t/020-fifottl.t | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/queue/abstract/driver/fifottl.lua b/queue/abstract/driver/fifottl.lua index 617a90b..bacfa85 100644 --- a/queue/abstract/driver/fifottl.lua +++ b/queue/abstract/driver/fifottl.lua @@ -164,7 +164,7 @@ local function fifottl_fiber(self) while true do if not box.cfg.read_only then local stat, err = pcall(fifottl_fiber_iteration, self, processed) - if not stat and not err.code == box.error.READONLY then + if not stat and not (err.code == box.error.READONLY) then log.error("error catched: %s", tostring(err)) log.error("exiting fiber '%s'", fiber.name()) return 1 diff --git a/t/020-fifottl.t b/t/020-fifottl.t index cfbcf45..dfeceaf 100755 --- a/t/020-fifottl.t +++ b/t/020-fifottl.t @@ -2,7 +2,7 @@ local fiber = require('fiber') local test = require('tap').test() -test:plan(14) +test:plan(15) local queue = require('queue') local state = require('queue.abstract.state') @@ -245,6 +245,23 @@ test:test('ttl after delay test', function(test) test:is(task.ttr, TTR * 1000000, 'check TTR after release') end) +-- gh-96: infinite loop after dropping a tube with a burried task +test:test('buried task in a dropped queue', function(test) + test:plan(1) + + local TASK_ID = 1 + local tube = queue.create_tube('test_drop_with_burried', 'fifottl', + {ttr = 0.1, if_not_exist = true}) + + tube:put({foo = 'bar'}) + local task = tube:take(0) + tube:bury(task[TASK_ID]) + + tube:drop() + fiber.sleep(0.2) + test:ok(true, 'queue does not hang') +end) + tnt.finish() os.exit(test:check() == true and 0 or -1)