[tarantool-patches] [PATCH v3 2/5] Synchronize lua schema update with space cache
Vladimir Davydov
vdavydov.dev at gmail.com
Wed Mar 27 13:32:29 MSK 2019
On Wed, Mar 27, 2019 at 01:03:51PM +0300, Vladimir Davydov wrote:
> On Fri, Mar 22, 2019 at 03:06:07PM +0300, Georgy Kirichenko wrote:
> > Update lua schema as soon as space cache replace was done instead of
> > doing this while on_commit trigger executes. In opposite then case
> > schema changes would not be visible until commit was finished.
> >
> > Needed for: #2798
> > ---
> > src/box/alter.cc | 13 ++++++++-----
> > 1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/box/alter.cc b/src/box/alter.cc
> > index daaa9cd57..275e39dd5 100644
> > --- a/src/box/alter.cc
> > +++ b/src/box/alter.cc
> > @@ -750,8 +750,6 @@ alter_space_commit(struct trigger *trigger, void *event)
> > op->commit(alter, txn->signature);
> > }
> >
> > - trigger_run_xc(&on_alter_space, alter->new_space);
> > -
> > alter->new_space = NULL; /* for alter_space_delete(). */
> > /*
> > * Delete the old version of the space, we are not
> > @@ -787,6 +785,8 @@ alter_space_rollback(struct trigger *trigger, void * /* event */)
> > space_swap_triggers(alter->new_space, alter->old_space);
> > space_swap_fk_constraints(alter->new_space, alter->old_space);
> > space_cache_replace(alter->new_space, alter->old_space);
> > + trigger_run(&on_alter_space, alter->old_space);
> > +
> > alter_space_delete(alter);
> > }
> >
> > @@ -888,6 +888,7 @@ alter_space_do(struct txn *txn, struct alter_space *alter)
> > * cache with it.
> > */
> > space_cache_replace(alter->old_space, alter->new_space);
> > + trigger_run_xc(&on_alter_space, alter->new_space);
>
> The comment right above says that this function must not throw an
> exception here so I guess we should use _xc free variant. Not that it
> really matters, as on_alter_space trigger can only fail on OOM, which
> is hardly ever possible.
Guess we should simply fold trigger_run_xc in space_cache_replace and
panic on error.
BTW this is how things were before
commit 1f736583361f537c8e1fb4ea0df0b92ee8d50c6d
Author: Vladimir Davydov <vdavydov.dev at gmail.com>
Date: Tue Sep 19 14:21:59 2017 +0300
box: use trigger to push space data to Lua
Currently, it is done by space_cache_replace/delete which violates
incapsulation. Let's introduce a trigger that is fired after a change in
a space definition is committed and use it to propagate changes to Lua.
Patch by @kostja.
More information about the Tarantool-patches
mailing list