Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Georgy Kirichenko <georgy@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [PATCH 1/3] Abort vinyl index creation in case of truncation rollback
Date: Thu, 21 Mar 2019 23:16:53 +0300	[thread overview]
Message-ID: <20190321201653.va4tg4lsqtrjzqx6@esperanza> (raw)
In-Reply-To: <9e71736be4cc6add4fc856ae8756fcc24b04f4e6.1553112720.git.georgy@tarantool.org>

On Wed, Mar 20, 2019 at 11:31:33PM +0300, Georgy Kirichenko wrote:
> Abort index create if truncate couldn't be finished because of rollback
> or error. Without this vinyl will fail because of internal scheduler
> assertion.
> 
> Needed for: 2798
> ---
>  src/box/alter.cc            |  8 ++++++++
>  test/engine/errinj.result   | 34 ++++++++++++++++++++++++++++++++++
>  test/engine/errinj.test.lua | 12 ++++++++++++
>  test/engine/suite.ini       |  1 +
>  4 files changed, 55 insertions(+)
>  create mode 100644 test/engine/errinj.result
>  create mode 100644 test/engine/errinj.test.lua
> 
> diff --git a/src/box/alter.cc b/src/box/alter.cc
> index 431da12da..84e74ee89 100644
> --- a/src/box/alter.cc
> +++ b/src/box/alter.cc
> @@ -1312,6 +1312,7 @@ public:
>  	uint32_t iid;
>  	virtual void prepare(struct alter_space *alter);
>  	virtual void commit(struct alter_space *alter, int64_t signature);
> +	virtual void rollback(struct alter_space *alter);
>  };
>  
>  void
> @@ -1349,6 +1350,13 @@ TruncateIndex::commit(struct alter_space *alter, int64_t signature)
>  	index_commit_create(new_index, signature);
>  }
>  
> +void
> +TruncateIndex::rollback(struct alter_space *alter)
> +{
> +	struct index *new_index = space_index(alter->new_space, iid);
> +	index_abort_create(new_index);
> +}
> +

Strictly speaking, it isn't quite correct to do this from 'rollback'
callback, because the latter is called only if alter_space_do()
succeeded, which may not be the case. I think you better do this from
TruncateIndex destructor. Take a look at CreateIndex and RebuildIndex
for the reference.

>  /**
>   * UpdateSchemaVersion - increment schema_version. Used on
>   * in alter_space_do(), i.e. when creating or dropping
> diff --git a/test/engine/errinj.result b/test/engine/errinj.result
> new file mode 100644
> index 000000000..37fc280b9
> --- /dev/null
> +++ b/test/engine/errinj.result
> @@ -0,0 +1,34 @@
> +test_run = require('test_run')
> +---
> +...
> +inspector = test_run.new()
> +---
> +...
> +engine = inspector:get_cfg('engine')
> +---
> +...
> +errinj = box.error.injection
> +---
> +...
> +-- test truncate rollback does not abort

I can't parse this comment. Let's rephrase it:

 --
 -- Check that on WAL write error space.truncate is rolled back properly.
 --

> +s = box.schema.space.create('truncate_rollback', {engine = engine})
> +---
> +...
> +_ = s:create_index('pk')

Please create a secondary index too.

Also, insert a few rows into the index and check that they are still
there after failed s.truncate.

> +---
> +...
> +errinj.set('ERRINJ_WAL_IO', true)
> +---
> +- ok
> +...
> +s:truncate()
> +---
> +- error: Failed to write to disk
> +...
> +errinj.set('ERRINJ_WAL_IO', false)
> +---
> +- ok
> +...
> +s:drop()
> +---
> +...

  reply	other threads:[~2019-03-21 20:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 20:31 [tarantool-patches] [PATCH 0/3] Enable ddl between begin and commit statements Georgy Kirichenko
2019-03-20 20:31 ` [tarantool-patches] [PATCH 1/3] Abort vinyl index creation in case of truncation rollback Georgy Kirichenko
2019-03-21 20:16   ` Vladimir Davydov [this message]
2019-03-20 20:31 ` [tarantool-patches] [PATCH 2/3] Synchronize lua schema update with space cache Georgy Kirichenko
2019-03-20 20:31 ` [tarantool-patches] [PATCH 3/3] Require for single statement not autocommit in case of ddl Georgy Kirichenko

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=20190321201653.va4tg4lsqtrjzqx6@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 1/3] Abort vinyl index creation in case of truncation rollback' \
    /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