From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladimir Davydov <vdavydov@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] box: allow upgrading from version 1.6
Date: Fri, 13 Aug 2021 13:47:51 +0300 [thread overview]
Message-ID: <193b13bc-f440-1181-fa5c-fd8f8bf06562@tarantool.org> (raw)
In-Reply-To: <20210813075438.4qcxnemi7yr72gwe@esperanza>
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
prev parent reply other threads:[~2021-08-13 10:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 11:28 Serge Petrenko via Tarantool-patches
2021-08-10 14:43 ` Sergey Ostanevich via Tarantool-patches
2021-08-11 12:36 ` Serge Petrenko via Tarantool-patches
2021-08-11 11:06 ` Vladimir Davydov via Tarantool-patches
2021-08-12 23:20 ` Serge Petrenko via Tarantool-patches
2021-08-13 7:54 ` Vladimir Davydov via Tarantool-patches
2021-08-13 10:47 ` Serge Petrenko via Tarantool-patches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=193b13bc-f440-1181-fa5c-fd8f8bf06562@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=sergepetrenko@tarantool.org \
--cc=vdavydov@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH] box: allow upgrading from version 1.6' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox