From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 297F06EC40; Fri, 13 Aug 2021 13:47:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 297F06EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628851674; bh=oWVln7UpC+ACHVtSFP8UL5uBzdLCgiZJtStb3pczLvQ=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=vyB7XSZe3Lm2NTihcEJFKYTXP7UDa0v6uTq3k+IEScnk9Edxc91Qf+7en/RKtO6Bn 7Ii3l3d+ScAqm6e1/psUi+lYJ2ZTwu4POCRQh5Bwf3d2J+ylTtcmsIsJ/rR53bXikz y/uloaJagDsQUujhY9VS0TuLM+85ioqHeZeVRNig= Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 DA25D6EC40 for ; Fri, 13 Aug 2021 13:47:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DA25D6EC40 Received: by smtp54.i.mail.ru with esmtpa (envelope-from ) id 1mEUj9-0001q5-Px; Fri, 13 Aug 2021 13:47:52 +0300 To: Vladimir Davydov References: <20210810112836.48775-1-sergepetrenko@tarantool.org> <20210811110654.y3xyaojebckp6flq@esperanza> <90eeefb5-3719-3198-dec7-4f00834733e7@tarantool.org> <20210813075438.4qcxnemi7yr72gwe@esperanza> Message-ID: <193b13bc-f440-1181-fa5c-fd8f8bf06562@tarantool.org> Date: Fri, 13 Aug 2021 13:47:51 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210813075438.4qcxnemi7yr72gwe@esperanza> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9736CF3E71F18CE0C3E1D5927724F4AAA182A05F538085040B721631418C1BFF03B369211AC00584EB8EE05985114C6A0C324DF58FD972375 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE706EA9E10470DC775EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371E8C7BD479B346ED8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83B118D2AF77550ED7C96853BBA46995A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE7B96B19DC40933214AAC223A686B1DECD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE362B3BD3CC35DA588040F9FF01DFDA4A8C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637C3090DF2C0002BD1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5956C5D542D564418C0323D969873812973D271DEF64DE5B1D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA750E14360347543F58410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3494FB0335DF05DC3A21763AB22864E8C5054A97A948F168F3142C57FA9155D1F1F5B5A15F8617A7E21D7E09C32AA3244C01571647CABC63BFB031A83D12C5D6F0F26BFA4C8A6946B8FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0dLV0c3jbkyJ2O2lHyGSyw== X-Mailru-Sender: 583F1D7ACE8F49BD31DE23046B3A84601B8EAAC83492F27842B615291F22C05BC1915BEC0767431A6BB2E709EA627F343C7DDD459B58856F0E45BC603594F5A135B915D4279FF0579437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] box: allow upgrading from version 1.6 X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 13.08.2021 10:54, Vladimir Davydov пишет: > On Fri, Aug 13, 2021 at 02:20:23AM +0300, Serge Petrenko wrote: >>>> +local function on_init_set_recovery_triggers() >>>> + log.info("Recovering snapshot with schema version %s", snap_version) >>>> + for _, trig_tbl in ipairs(recovery_triggers) do >>>> + if trig_tbl.version >= snap_version then >>>> + for space, trig in pairs(trig_tbl.tbl) do >>>> + box.space[space]:before_replace(trig) >>>> + log.info("Set recovery trigger on space '%s' to comply with ".. >>>> + "version %s format", space, trig_tbl.version) >>>> + end >>>> + end >>>> + end >>>> +end >>>> + >>>> +local function set_recovery_triggers(version) >>>> + snap_version = version >>>> + box.ctl.on_schema_init(on_init_set_recovery_triggers) >>>> +end >>> Please don't use a global variable for this - it's bad for encapsulation >>> and generally make code more difficult to follow. Pass version >>> explicitly to all functions that need it. >> I can't do that for an on_schema_init trigger, unfortunately. >> Am I missing something? Looks like there's no way to pass trigger.data >> for lua triggers. > You can capture a value in a lambda: > > box.ctl.on_schema_init(function() > on_init_set_recover_triggers(snap_version) > end) Wow, indeed. Thanks! I didn't apply that in v2 though, because now I have some places which modify snap_version (which's now called trig_oldest_version): local function schema_trig_last(_, tuple)     ...     clear_recovery_triggers(version_from_tuple)     trig_oldest_version = version_from_tuple end local function clear_recovery_triggers(up_to_version)     -- Clear triggers starting from trig_oldest_version up to up_to_version.     ... end -- Serge Petrenko