From 5919f465b27aa1197b13ca77de1925940bf17745 Mon Sep 17 00:00:00 2001 From: Vladislav Grubov Date: Mon, 22 Jul 2024 16:17:54 +0300 Subject: [PATCH] fix: pcall(box.ctl.wait_rw) and logs spam in backround fibers --- xqueue.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/xqueue.lua b/xqueue.lua index 145f7c2..c3af090 100644 --- a/xqueue.lua +++ b/xqueue.lua @@ -821,7 +821,7 @@ function M.upgrade(space,opts,depth) log.verbose("awaiting rw") repeat if box.ctl.wait_rw then - box.ctl.wait_rw(1) + pcall(box.ctl.wait_rw, 1) else fiber.sleep(0.001) end @@ -849,11 +849,7 @@ function M.upgrade(space,opts,depth) repeat fiber.sleep(0.001) until space.xq if xq.ready then xq.ready:get() end log.info("I am worker %s",i) - if box.info.ro then - log.info("Shutting down on ro instance") - return - end - while box.space[space.name] and space.xq == xq do + while box.space[space.name] and space.xq == xq and not box.info.ro do if xq.ready then xq.ready:get() end local task = space:take(1) if task then @@ -873,6 +869,10 @@ function M.upgrade(space,opts,depth) end fiber.yield() end + if box.info.ro then + log.info("Shutting down on ro instance") + return + end log.info("worker %s ended", i) end,space,self) end @@ -888,14 +888,10 @@ function M.upgrade(space,opts,depth) if xq.ready then xq.ready:get() end local chan = xq.runat_chan log.info("Runat started") - if box.info.ro then - log.info("Shutting down on ro instance") - return - end local maxrun = 1000 local curwait local collect = {} - while box.space[space.name] and space.xq == xq do + while box.space[space.name] and space.xq == xq and not box.info.ro do local r,e = pcall(function() -- print("runat loop 2 ",box.time64()) local remaining @@ -972,6 +968,10 @@ function M.upgrade(space,opts,depth) if curwait == 0 then fiber.sleep(0) end chan:get(curwait) end + if box.info.ro then + log.info("Shutting down on ro instance") + return + end log.info("Runat ended") end,space,self,runat_index) end