From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Georgy Kirichenko <georgy@tarantool.org>
Subject: [tarantool-patches] [PATCH v3 1/5] Abort vinyl index creation in case of truncation rollback
Date: Fri, 22 Mar 2019 15:06:06 +0300 [thread overview]
Message-ID: <6781097cb02acfa6b5cdc102fafa7045a1682e05.1553255718.git.georgy@tarantool.org> (raw)
In-Reply-To: <cover.1553255718.git.georgy@tarantool.org>
Abort a new index creation if truncate couldn't be finished because of
rollback or an error. Without this vinyl fails because of internal
scheduler assertion.
Needed for: 2798
---
src/box/alter.cc | 13 +++++++--
test/engine/errinj.result | 53 +++++++++++++++++++++++++++++++++++++
test/engine/errinj.test.lua | 15 +++++++++++
test/engine/suite.ini | 1 +
4 files changed, 80 insertions(+), 2 deletions(-)
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 080a72b9f..daaa9cd57 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -1310,13 +1310,16 @@ public:
: AlterSpaceOp(alter), iid(iid) {}
/** id of the index to truncate. */
uint32_t iid;
+ struct index *new_index;
virtual void prepare(struct alter_space *alter);
virtual void commit(struct alter_space *alter, int64_t signature);
+ virtual ~TruncateIndex();
};
void
TruncateIndex::prepare(struct alter_space *alter)
{
+ new_index = space_index(alter->new_space, iid);
if (iid == 0) {
/*
* Notify the engine that the primary index
@@ -1333,7 +1336,6 @@ TruncateIndex::prepare(struct alter_space *alter)
* index was recreated. For example, Vinyl uses this
* callback to load indexes during local recovery.
*/
- struct index *new_index = space_index(alter->new_space, iid);
assert(new_index != NULL);
space_build_index_xc(alter->new_space, new_index,
alter->new_space->format);
@@ -1343,10 +1345,17 @@ void
TruncateIndex::commit(struct alter_space *alter, int64_t signature)
{
struct index *old_index = space_index(alter->old_space, iid);
- struct index *new_index = space_index(alter->new_space, iid);
index_commit_drop(old_index, signature);
index_commit_create(new_index, signature);
+ new_index = NULL;
+}
+
+TruncateIndex::~TruncateIndex()
+{
+ if (new_index == NULL)
+ return;
+ index_abort_create(new_index);
}
/**
diff --git a/test/engine/errinj.result b/test/engine/errinj.result
new file mode 100644
index 000000000..d244c334a
--- /dev/null
+++ b/test/engine/errinj.result
@@ -0,0 +1,53 @@
+test_run = require('test_run')
+---
+...
+inspector = test_run.new()
+---
+...
+engine = inspector:get_cfg('engine')
+---
+...
+errinj = box.error.injection
+---
+...
+-- truncation rollback should not crash
+s = box.schema.space.create('truncate_rollback', {engine = engine})
+---
+...
+_ = s:create_index('pk')
+---
+...
+_ = s:create_index('sk', {parts = {1, 'int'}})
+---
+...
+for i = 1, 10 do s:replace({i, i}) end
+---
+...
+errinj.set('ERRINJ_WAL_IO', true)
+---
+- ok
+...
+s:truncate()
+---
+- error: Failed to write to disk
+...
+errinj.set('ERRINJ_WAL_IO', false)
+---
+- ok
+...
+s:select()
+---
+- - [1, 1]
+ - [2, 2]
+ - [3, 3]
+ - [4, 4]
+ - [5, 5]
+ - [6, 6]
+ - [7, 7]
+ - [8, 8]
+ - [9, 9]
+ - [10, 10]
+...
+s:drop()
+---
+...
diff --git a/test/engine/errinj.test.lua b/test/engine/errinj.test.lua
new file mode 100644
index 000000000..57f3a962c
--- /dev/null
+++ b/test/engine/errinj.test.lua
@@ -0,0 +1,15 @@
+test_run = require('test_run')
+inspector = test_run.new()
+engine = inspector:get_cfg('engine')
+errinj = box.error.injection
+
+-- truncation rollback should not crash
+s = box.schema.space.create('truncate_rollback', {engine = engine})
+_ = s:create_index('pk')
+_ = s:create_index('sk', {parts = {1, 'int'}})
+for i = 1, 10 do s:replace({i, i}) end
+errinj.set('ERRINJ_WAL_IO', true)
+s:truncate()
+errinj.set('ERRINJ_WAL_IO', false)
+s:select()
+s:drop()
diff --git a/test/engine/suite.ini b/test/engine/suite.ini
index 3f82a1325..3db02ab6f 100644
--- a/test/engine/suite.ini
+++ b/test/engine/suite.ini
@@ -3,6 +3,7 @@ core = tarantool
description = tarantool multiengine tests
script = box.lua
use_unix_sockets = True
+release_disabled = errinj.test.lua
config = engine.cfg
#disabled = replica_join.test.lua
lua_libs = conflict.lua ../box/lua/utils.lua ../box/lua/push.lua
--
2.21.0
next prev parent reply other threads:[~2019-03-22 12:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 12:06 [tarantool-patches] [PATCH v3 0/5] Transaction in replication protocol Georgy Kirichenko
2019-03-22 12:06 ` Georgy Kirichenko [this message]
2019-03-27 9:59 ` [tarantool-patches] [PATCH v3 1/5] Abort vinyl index creation in case of truncation rollback Vladimir Davydov
2019-03-22 12:06 ` [tarantool-patches] [PATCH v3 2/5] Synchronize lua schema update with space cache Georgy Kirichenko
2019-03-27 10:03 ` Vladimir Davydov
2019-03-27 10:32 ` Vladimir Davydov
2019-03-27 11:45 ` [tarantool-patches] " Konstantin Osipov
2019-03-22 12:06 ` [tarantool-patches] [PATCH v3 3/5] Require for single statement not autocommit in case of ddl Georgy Kirichenko
2019-03-27 10:49 ` Vladimir Davydov
2019-03-22 12:06 ` [tarantool-patches] [PATCH v3 4/5] Transaction support for applier Georgy Kirichenko
2019-03-27 11:41 ` Vladimir Davydov
2019-03-27 11:48 ` Vladimir Davydov
2019-03-22 12:06 ` [tarantool-patches] [PATCH v3 5/5] Raise an error if remote transaction produces non-local changes Georgy Kirichenko
2019-03-27 12:06 ` 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=6781097cb02acfa6b5cdc102fafa7045a1682e05.1553255718.git.georgy@tarantool.org \
--to=georgy@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v3 1/5] 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