Tarantool development patches archive
 help / color / mirror / Atom feed
From: Konstantin Osipov <kostja@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com, Serge Petrenko <sergepetrenko@tarantool.org>
Subject: Re: [tarantool-patches] [PATCH] box: add on_schema_init trigger
Date: Tue, 5 Mar 2019 10:54:54 +0300	[thread overview]
Message-ID: <20190305075454.GI21955@chai> (raw)
In-Reply-To: <20190302123149.5115-1-sergepetrenko@tarantool.org>

* 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.

> +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.


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

  reply	other threads:[~2019-03-05  7:54 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 ` Konstantin Osipov [this message]
2019-03-05 10:34   ` [tarantool-patches] " Vladimir Davydov

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=20190305075454.GI21955@chai \
    --to=kostja@tarantool.org \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --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