From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F04ED46970E for ; Mon, 27 Jan 2020 15:27:29 +0300 (MSK) References: <4fdff09679c5a82c5f845343895b9d54be39b653.1576658855.git.lvasiliev@tarantool.org> From: Leonid Vasiliev Message-ID: Date: Mon, 27 Jan 2020 15:27:28 +0300 MIME-Version: 1.0 In-Reply-To: <4fdff09679c5a82c5f845343895b9d54be39b653.1576658855.git.lvasiliev@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH] Release all taken tasks on start List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Add some stylistic edits --- diff --git a/queue/abstract.lua b/queue/abstract.lua index ed07d85..3c26d35 100644 --- a/queue/abstract.lua +++ b/queue/abstract.lua @@ -516,10 +516,12 @@ function method.start() tube = recreate_tube(tube_tuple) local space = box.space[space_name] for _, task_tuple in space:pairs() do - -- Release all taken tasks - local tid, task_state = task_tuple:unpack() + -- Release all taken tasks on start + -- See https://github.com/tarantool/queue/issues/66 + -- for more information + local tid, task_state = task_tuple[1], task_tuple[2] if task_state == state.TAKEN then - tube.raw:release(tid, {}) + tube.raw:release(tid) end end end On 12/18/19 11:52 AM, Leonid Vasiliev wrote: > https://github.com/tarantool/queue/issues/66 > https://github.com/tarantool/queue/tree/lvasiliev/gh-66-release-taken-tasks-after-reboot > > 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. > > --- > queue/abstract.lua | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/queue/abstract.lua b/queue/abstract.lua > index ad8817d..ed07d85 100644 > --- a/queue/abstract.lua > +++ b/queue/abstract.lua > @@ -511,7 +511,18 @@ function method.start() > }) > end > > - _queue:pairs():each(recreate_tube) > + for _, tube_tuple in _queue:pairs() do > + local space_name = tube_tuple[3] > + tube = recreate_tube(tube_tuple) > + local space = box.space[space_name] > + for _, task_tuple in space:pairs() do > + -- Release all taken tasks > + local tid, task_state = task_tuple:unpack() > + if task_state == state.TAKEN then > + tube.raw:release(tid, {}) > + end > + end > + end > > session.on_disconnect(queue._on_consumer_disconnect) > return queue >