From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 2DA1346971A for ; Fri, 13 Dec 2019 13:46:36 +0300 (MSK) Date: Fri, 13 Dec 2019 13:44:26 +0300 From: Igor Munkin Message-ID: <20191213104426.GM1214@tarantool.org> References: <20191211235703.GK1214@tarantool.org> <175e0c98-8f2d-ff20-4280-63c7a3f90432@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <175e0c98-8f2d-ff20-4280-63c7a3f90432@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 1/2] fiber: unref fiber.storage via global Lua state List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Vlad, On 13.12.19, Vladislav Shpilevoy wrote: > Hi! Thanks for the review! > > On 12/12/2019 00:57, Igor Munkin wrote: > > Vlad, > > > > Thanks for the patch! > > > > I spent some time knee deep into fibers machinery and totally agree with > > this fix: the most safe approach is "unrefing" storage entity via > > tarantool_L coro, taking into account the possible unref of the fiber's > > one and its consequtive collection. > > > > However, I don't get why we need to apply these changes, considering > > your follow-up patch. Could you please provide a bit more detailed > > rationale? > > My follow up patch is about a different bug and I wanted to keep > these independent fixes separated. That would have been strange, > if in the second commit I had just silently replaced the old L > with tarantool_L. > Yes, on second thought I agree with you and Kostja, so here is my LGTM for this patch. > > > > On 08.12.19, Vladislav Shpilevoy wrote: > >> Fiber.storage is a table, available from anywhere in the fiber. It > >> is destroyed after fiber function is finished. That provides a > >> reliable fiber-local storage, similar to thread-local in C/C++. > >> > >> But there is a problem that the storage may be created via one > >> struct lua_State, and destroyed via another. Here is an example: > >> > >> function test_storage() > >> fiber.self().storage.key = 100 > >> end > >> box.schema.func.create('test_storage') > >> _ = fiber.create(function() > >> box.func.test_storage:call() > >> end) > >> > >> There are 3 struct lua_State: > >> tarantool_L - global always alive Lua state; > >> L1 - stack of the fiber, created by fiber.create(); > >> L2 - stack created by that fiber to execute test_storage(). > > > > Minor: Strictly saying, lua_State is a Lua coroutine, and not just a > > guest stack. Please, consider adjusting the commit message, but feel > > free to ignore this remark. > > > > Agree, here is a new version of this paragraph: > > " > There are 3 struct lua_State: > tarantool_L - global always alive state; > L1 - Lua coroutine of the fiber, created by fiber.create(); > L2 - Lua coroutine created by that fiber to execute > test_storage(). > " -- Best regards, IM