Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Serge Petrenko <sergepetrenko@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 10:54:38 +0300	[thread overview]
Message-ID: <20210813075438.4qcxnemi7yr72gwe@esperanza> (raw)
In-Reply-To: <90eeefb5-3719-3198-dec7-4f00834733e7@tarantool.org>

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)

  reply	other threads:[~2021-08-13  7:54 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 [this message]
2021-08-13 10:47       ` Serge Petrenko via Tarantool-patches

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=20210813075438.4qcxnemi7yr72gwe@esperanza \
    --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