From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 27C1A2FFAE for ; Wed, 19 Jun 2019 08:48:29 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RxAbsayIM4xL for ; Wed, 19 Jun 2019 08:48:29 -0400 (EDT) Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 704742E9ED for ; Wed, 19 Jun 2019 08:48:28 -0400 (EDT) From: Stanislav Zudin Subject: [tarantool-patches] [PATCH] ddl: No replication for temp and local spaces Date: Wed, 19 Jun 2019 15:48:23 +0300 Message-Id: <20190619124823.7021-1-szudin@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, georgy@tarantool.org Cc: Stanislav Zudin Do not spread the space:truncate() to replicas if the affected space is local and temporary. Closes #4263 --- Branch: https://github.com/tarantool/tarantool/tree/stanztt/gh-4263-no-replica-tmplocal-space Issue: https://github.com/tarantool/tarantool/issues/4263 src/box/alter.cc | 10 ++++++ test/replication/local_spaces.result | 48 ++++++++++++++++++++++++++ test/replication/local_spaces.test.lua | 19 ++++++++++ 3 files changed, 77 insertions(+) diff --git a/src/box/alter.cc b/src/box/alter.cc index a37a68ce4..55d588511 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -2278,6 +2278,16 @@ on_replace_dd_truncate(struct trigger * /* trigger */, void *event) auto scoped_guard = make_scoped_guard([=] { alter_space_delete(alter); }); + /* + * Modify the WAL header to prohibit + * replication of local & temporary + * spaces truncation. + */ + if (space_is_temporary(old_space) && + space_group_id(old_space) == GROUP_LOCAL) { + stmt->row->group_id = GROUP_LOCAL; + } + /* * Recreate all indexes of the truncated space. */ diff --git a/test/replication/local_spaces.result b/test/replication/local_spaces.result index ed1b76da8..c36e21403 100644 --- a/test/replication/local_spaces.result +++ b/test/replication/local_spaces.result @@ -71,6 +71,22 @@ s3.temporary --- - true ... +-- The truncation of the local & temporary space should not +-- spread among the replicas +s4 = box.schema.space.create('test4', {is_local = true, temporary = true}) +--- +... +_ = s4:create_index('pk') +--- +... +s4.is_local +--- +- true +... +s4.temporary +--- +- true +... _ = s1:insert{1} --- ... @@ -80,6 +96,9 @@ _ = s2:insert{1} _ = s3:insert{1} --- ... +_ = s4:insert{1} +--- +... box.snapshot() --- - ok @@ -93,6 +112,16 @@ _ = s2:insert{2} _ = s3:insert{2} --- ... +_ = s4:insert{2} +--- +... +s4:truncate() +--- +... +box.space._truncate:select{} +--- +- - [515, 1] +... box.schema.user.grant('guest', 'replication') --- ... @@ -124,6 +153,14 @@ box.space.test3.temporary --- - true ... +box.space.test4.is_local +--- +- true +... +box.space.test4.temporary +--- +- true +... box.space.test1:select() --- - - [1] @@ -137,6 +174,14 @@ box.space.test3:select() --- - [] ... +box.space.test4:select() +--- +- [] +... +box.space._truncate:select{} +--- +- [] +... box.cfg{read_only = true} -- local spaces ignore read_only --- ... @@ -253,3 +298,6 @@ s2:drop() s3:drop() --- ... +s4:drop() +--- +... diff --git a/test/replication/local_spaces.test.lua b/test/replication/local_spaces.test.lua index bb7294538..01fbeeb70 100644 --- a/test/replication/local_spaces.test.lua +++ b/test/replication/local_spaces.test.lua @@ -33,13 +33,25 @@ _ = s3:create_index('pk') s3.is_local s3.temporary +-- The truncation of the local & temporary space should not +-- spread among the replicas +s4 = box.schema.space.create('test4', {is_local = true, temporary = true}) +_ = s4:create_index('pk') +s4.is_local +s4.temporary + _ = s1:insert{1} _ = s2:insert{1} _ = s3:insert{1} +_ = s4:insert{1} box.snapshot() _ = s1:insert{2} _ = s2:insert{2} _ = s3:insert{2} +_ = s4:insert{2} + +s4:truncate() +box.space._truncate:select{} box.schema.user.grant('guest', 'replication') test_run:cmd("create server replica with rpl_master=default, script='replication/replica.lua'") @@ -50,9 +62,15 @@ box.space.test1.is_local box.space.test2.is_local box.space.test3.is_local box.space.test3.temporary +box.space.test4.is_local +box.space.test4.temporary box.space.test1:select() box.space.test2:select() box.space.test3:select() +box.space.test4:select() + +box.space._truncate:select{} + box.cfg{read_only = true} -- local spaces ignore read_only for i = 1, 3 do box.space.test2:insert{i, i} end for i = 1, 3 do box.space.test3:insert{i, i, i} end @@ -87,3 +105,4 @@ s3:select() s1:drop() s2:drop() s3:drop() +s4:drop() -- 2.17.1