From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Konstantin Osipov <kostja@tarantool.org> Cc: tarantool-patches@freelists.org, Serge Petrenko <sergepetrenko@tarantool.org> Subject: Re: [tarantool-patches] [PATCH] box: add on_schema_init trigger Date: Tue, 5 Mar 2019 13:34:48 +0300 [thread overview] Message-ID: <20190305103448.ijwf5c2ig35sdj4u@esperanza> (raw) In-Reply-To: <20190305075454.GI21955@chai> On Tue, Mar 05, 2019 at 10:54:54AM +0300, Konstantin Osipov wrote: > * Serge Petrenko <sergepetrenko@tarantool.org> [19/03/03 23:25]: > > This patch introduces an on_schema_init trigger. The trigger may be set > > before box.cfg() is called and is called during box.cfg() right after > > prototypes of system spaces, such as _space, are created. This allows to > > set triggers on system spaces before any other non-system data is > > recovered. For example, it is possible to set an on_replace trigger on > > _space, which will work even during recovery. > > > > Part of #3159 > > > > @TarantoolBot document > > Title: document box.ctl.on_schema_init triggers > > on_schema_init triggers are set before the first call to box.cfg() and > > are fired during box.cfg() before user data recovery start. > > Please explain in the docbot request why we're adding this with > an example: provide the docs team with a full example how to use > these triggers to easily change space engine type in replication events > or make a space on a replicate "terminate" in replication by > changing its group id to GROUP_LOCAL. > > > > > diff --git a/src/box/lua/ctl.c b/src/box/lua/ctl.c > > index 7010be138..0767cf476 100644 > > --- a/src/box/lua/ctl.c > > +++ b/src/box/lua/ctl.c > > @@ -40,6 +40,7 @@ > > #include "lua/trigger.h" > > > > #include "box/box.h" > > +#include "box/schema.h" /* on_schema_init triggers */ > > > Please move the declaration to a more suitable place (box/box.h?) > to avoid polluting the include list. IMO having on_schema_init defined in schema.cc (we can't move it to box.cc) and declared in box.h would look confusing. > > > +trig = box.ctl.on_schema_init(testing_trig) > > +test:is(type(trig), 'function', 'on_schema_init trigger set') > > + > > +box.cfg{log = 'tarantool.log'} > > +test:like(str, 'on_schema_init', 'on_schema_init trigger works') > > +str = '' > > +box.schema.space.create("test") > > +-- test that _space.on_replace trigger may be set in on_schema_init > > +test:like(str, '_space:on_replace', 'can set on_replace') > > +test:check() > > +box.space.test:drop() > > +os.exit(0) > > Please write a full test for changed storage engine on replica *in > addition to* this unit test. Another test for replica-local spaces > on replica won't hurt. Nit: I'd also rename the test from box-tap/ctl_on_schema_init.test.lua to box-tap/on_schema_init.test.lua.
prev parent reply other threads:[~2019-03-05 10:34 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-02 12:31 Serge Petrenko 2019-03-05 7:54 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 10:34 ` Vladimir Davydov [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=20190305103448.ijwf5c2ig35sdj4u@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH] box: add on_schema_init trigger' \ /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