Tarantool development patches archive
 help / color / mirror / Atom feed
From: Konstantin Osipov <kostja@tarantool.org>
To: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] Re: [PATCH 08/12] alter: introduce preparation phase
Date: Tue, 10 Apr 2018 11:46:09 +0300	[thread overview]
Message-ID: <20180410084609.GQ4527@atlas> (raw)
In-Reply-To: <20180410083159.4x3t6uo4xctl73ze@esperanza>

* Vladimir Davydov <vdavydov.dev@gmail.com> [18/04/10 11:32]:
> The problem is that we first call 'prepare' for all registered
> operations. If 'prepare' fails for any of those operations, we
> need to undo its effect for all operations for which 'prepare'
> succeeded. I see the following ways of doing this:
> 
>  - Reuse 'rollback' for undoing the effect of 'prepare', but this way we
>    would have to be able to differentiate between 'rollback' after WAL
>    error and 'rollback' after 'prepare' for all operations, even those
>    that don't use 'prepare' at all, e.g. ModifySpace. This would look
>    convoluted IMO.
> 
>  - Undo the effect of 'prepare' in destructor. I don't like it, because
>    IMO destructor should be used only for freeing up resources. Calling,
>    for example, index_abort_create() from it would look ugly IMO.

I prefer this option. I don't see why we need two functions simply
because "destructor should be used only for freeing up resources".
Let's drop C++ there altogether and forget this argument, if it
makes it easier.
> 
>  - Introduce 'abort' that would undo the effect of 'prepare'. All things
>    considered, I find it the best way to go from the code readability
>    point of view.
> 
> > 
> > > While we are at it, let's also add some comments to AlterSpaceOp
> > > methods.
> > > ---
> > >  src/box/alter.cc | 104 ++++++++++++++++++++++++++++++++++++++++++++++---------
> > >  1 file changed, 88 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/src/box/alter.cc b/src/box/alter.cc
> > > index 9dd8d8d5..f5996850 100644
> > > --- a/src/box/alter.cc
> > > +++ b/src/box/alter.cc
> > > @@ -614,12 +614,48 @@ struct alter_space;
> > >  class AlterSpaceOp {
> > >  public:
> > >  	AlterSpaceOp(struct alter_space *alter);
> > > +
> > > +	/** Link in alter_space::ops. */
> > >  	struct rlist link;
> > > +	/**
> > > +	 * Called before creating the new space. Used to update
> > > +	 * the space definition and/or key list that will be used
> > > +	 * for creating the new space. Must not yield or fail.
> > > +	 */
> > >  	virtual void alter_def(struct alter_space * /* alter */) {}
> > > +	/**
> > > +	 * Called after creating a new space. Used for performing
> > > +	 * long-lasting operations, such as index rebuild or format
> > > +	 * check. May yield. May throw an exception. Must not modify
> > > +	 * the old space.
> > > +	 */
> > > +	virtual void prepare(struct alter_space * /* alter */) {}
> > > +	/**
> > > +	 * Called if the preparation phase failed after this
> > > +	 * operation has been successfully prepared. Supposed
> > > +	 * to undo the effect of AlterSpaceOp::prepare.
> > > +	 */
> > > +	virtual void abort(struct alter_space * /* alter */) {}
> > > +	/**
> > > +	 * Called after all registered operations have completed
> > > +	 * the preparation phase. Used to propagate the old space
> > > +	 * state to the new space (e.g. move unchanged indexes).
> > > +	 * Must not yield or fail.
> > > +	 */
> > >  	virtual void alter(struct alter_space * /* alter */) {}
> > > +	/**
> > > +	 * Called after the change has been successfully written
> > > +	 * to WAL. Must not fail.
> > > +	 */
> > >  	virtual void commit(struct alter_space * /* alter */,
> > >  			    int64_t /* signature */) {}
> > > +	/**
> > > +	 * Called in case a WAL error occurred. It is supposed to undo
> > > +	 * the effect of AlterSpaceOp::prepare and AlterSpaceOp::alter.
> > > +	 * Must not fail.
> > > +	 */
> > >  	virtual void rollback(struct alter_space * /* alter */) {}
> > > +
> > >  	virtual ~AlterSpaceOp() {}
> > >  
> > >  	void *operator new(size_t size)
> > > @@ -657,6 +693,12 @@ struct alter_space {
> > >  	/** New space. */
> > >  	struct space *new_space;
> > >  	/**
> > > +	 * Space used as the source when building a new index.
> > > +	 * Initially it is set to old_space, but may be reset
> > > +	 * to new_space if the primary key is recreated.
> > > +	 */
> > > +	struct space *source_space;
> > 
> > Sounds like this shouldn't be in alter, but should be in its own
> > op designated to recreation of the primary key.
> 
> We need to update it for all CreateIndex operations, whenever we detect
> that the primary index is truncated, i.e. CreateIndex is called for the
> primary index. I haven't figured out a better way to do it. We might
> need to discuss it f2f.

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

  reply	other threads:[~2018-04-10  8:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07 13:37 [PATCH 00/12] vinyl: allow to modify format of non-empty spaces Vladimir Davydov
2018-04-07 13:37 ` [PATCH 01/12] alter: introduce CheckSpaceFormat AlterSpaceOp for validating format Vladimir Davydov
2018-04-09 20:25   ` Konstantin Osipov
2018-04-07 13:37 ` [PATCH 02/12] alter: fold ModifySpaceFormat into ModifySpace Vladimir Davydov
2018-04-09 20:26   ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 03/12] alter: move dictionary update from ModifySpace::alter_def to alter Vladimir Davydov
2018-04-09 20:32   ` Konstantin Osipov
2018-04-10  7:53     ` Vladimir Davydov
2018-04-10 11:45     ` Vladimir Davydov
2018-04-07 13:38 ` [PATCH 04/12] alter: use space_index instead of index_find where appropriate Vladimir Davydov
2018-04-09 20:34   ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 05/12] alter: allocate triggers before the point of no return Vladimir Davydov
2018-04-09 20:36   ` Konstantin Osipov
2018-04-10  7:57     ` Vladimir Davydov
2018-04-10 11:54       ` Vladimir Davydov
2018-04-07 13:38 ` [PATCH 06/12] space: space_vtab::build_secondary_key => build_index Vladimir Davydov
2018-04-09 20:39   ` Konstantin Osipov
2018-04-10  8:05     ` Vladimir Davydov
2018-04-10 12:14       ` Vladimir Davydov
2018-04-07 13:38 ` [PATCH 07/12] space: pass new format instead of new space to space_vtab::check_format Vladimir Davydov
2018-04-09 20:40   ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 08/12] alter: introduce preparation phase Vladimir Davydov
2018-04-09 20:46   ` [tarantool-patches] " Konstantin Osipov
2018-04-10  8:31     ` Vladimir Davydov
2018-04-10  8:46       ` Konstantin Osipov [this message]
2018-04-07 13:38 ` [PATCH 09/12] alter: zap space_def_check_compatibility Vladimir Davydov
2018-04-09 20:49   ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 10/12] vinyl: remove superfluous ddl checks Vladimir Davydov
2018-04-09 20:49   ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 11/12] vinyl: force index rebuild if indexed field type is narrowed Vladimir Davydov
2018-04-09 20:51   ` Konstantin Osipov
2018-04-07 13:38 ` [PATCH 12/12] vinyl: allow to modify format of non-empty spaces Vladimir Davydov
2018-04-09  8:24   ` Vladimir Davydov
2018-04-09 20:55   ` Konstantin Osipov

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=20180410084609.GQ4527@atlas \
    --to=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] Re: [PATCH 08/12] alter: introduce preparation phase' \
    /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