[Tarantool-patches] [PATCH] box: allow upgrading from version 1.6
Vladimir Davydov
vdavydov at tarantool.org
Fri Aug 13 10:54:38 MSK 2021
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)
More information about the Tarantool-patches
mailing list