From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 7929D71233; Fri, 29 Oct 2021 12:20:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7929D71233 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635499244; bh=yjner/aOl+VMAG7QJr3+NJsd0lBls7GIc5ZYh6K718I=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=hNmVwcJtOG780vysUWV5BWt4cubNhOyyr8ZBzvErebVNISLN+dqraUM1efvEaIBGB rI3GiD+e7550xVDorcbo+W+JBi68VqRVVFYxgPUvVwCtTe/E9qu9FeHJXZ3mES9+iC vpjJGTTEsRWHoqZ/ZMtTT0PaNo8G9wxmy5jCrERg= Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 071BE71233 for ; Fri, 29 Oct 2021 12:20:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 071BE71233 Received: by smtp3.mail.ru with esmtpa (envelope-from ) id 1mgO42-0005Qc-BC; Fri, 29 Oct 2021 12:20:42 +0300 Message-ID: <986cb3d1-64a9-87ec-8734-afe69c81c245@tarantool.org> Date: Fri, 29 Oct 2021 12:20:41 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-GB To: =?UTF-8?B?0K/QvSDQqNGC0YPQvdC00LXRgA==?= , tml References: <20211025104449.26693-1-ya.shtunder@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9E6B4260954843F6F28BBEFA2A848972EAE9FDA57E6794BE800894C459B0CD1B9667C2328366079266709F3E0052D33C869B0415A69AD719FAD6EBCE4B6B5C4E8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73C871DD2182510D5EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063790333AD7CC3E6A518638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D865A8C79C868DF855BC48C74C49E3C1EC117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CAD0E433DBF1FBFA32D242C3BD2E3F4C64AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C3542940D836FEAD38BA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE77DCDFB3399A2F72843847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A533CA2690BD4BF9CD270A6AF5D7B3E116EF066B33D025E0BAD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75C69C5C0DDE134364410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3442AF01057B6BF9978AC1285BEB3E73409E0AC4B10699D3360D390FBF4E6C6F952FB8B782990B8D921D7E09C32AA3244C6403338502901DF90564B657E46CE35995A9E0DC41E9A4CF729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojdMRfVmNkPDjDe+0xG/bjkw== X-Mailru-Sender: 583F1D7ACE8F49BD8518EAAA0E4F94F1F2D30E2FB7E693F4031D199641B867CC157D2ACA2F26722D424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3] replication: the truncate method called from within a transaction X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 28.10.2021 18:48, Ян Штундер пишет: > Hi! Thank you for the review! > I have fixed the errors > > Please, find a better test name. > Like "gh_6123_truncate_temp_space_test.lua" > > > gh_6123_test.lua -> gh_6123_truncate_temp_space_test.lua > > -- > Yan Shtunder > > Thanks  for the fixes! One comment left. I'm pasting part of the patch here to review. In test: +g.after_each(function(cg) +    cg.cluster.servers = nil +    cg.cluster:drop() +    fio.rmtree(cg.master.workdir) +    fio.rmtree(cg.replica.workdir) +end) + + +g.before_test('test_truncate_is_local_transaction', function(cg) +    cg.cluster:add_server(cg.master) +    cg.cluster:add_server(cg.replica) +    cg.cluster:start() +end) + +g.after_test('test_truncate_is_local_transaction', function(cg) +    cg.cluster:drop({cg.master, cg.replica}) +end) + You have a single test: test_truncate_is_local_transaction. So g.after_each and g.after_test both have the same meaning in your case. I propose to dorp g.after_test, since g.after_each supersedes it. Also, you don't need to call fio.rmtree in g.after_each. luatest does this for you, when needed. > > пн, 25 окт. 2021 г. в 16:34, Serge Petrenko : > > > > 25.10.2021 13:44, Yan Shtunder via Tarantool-patches пишет: > > The truncate method could be called from within a transaction. > The flag > > of GROUP_LOCAL was set in truncate method after statement row > had been > > being checked on the GROUP_LOCAL. Accordingly, after a local > transaction > > NOP row was not appended. > > > > Closes #6123 > > Thanks for the patch! > > Please, find 2 comments below. > > --- > > Issue: https://github.com/tarantool/tarantool/issues/6123 > > Patch: > https://github.com/tarantool/tarantool/tree/yshtunder/gh-6123-truncate-is-local-transaction > > > >   src/box/alter.cc                          |  5 ++ > >   test/replication-luatest/gh_6123_test.lua | 62 > +++++++++++++++++++++++ > >   2 files changed, 67 insertions(+) > >   create mode 100644 test/replication-luatest/gh_6123_test.lua > > > > diff --git a/src/box/alter.cc b/src/box/alter.cc > > index 31ac82fc5..52b9ea4d2 100644 > > --- a/src/box/alter.cc > > +++ b/src/box/alter.cc > > @@ -2914,6 +2914,11 @@ on_replace_dd_truncate(struct trigger * > /* trigger */, void *event) > >       if (space_is_temporary(old_space) || > >           space_group_id(old_space) == GROUP_LOCAL) { > >               stmt->row->group_id = GROUP_LOCAL; > > +             /* > > +              * The trigger is invoked after txn->n_local_rows > > +              * is counted, so don't forget to update it here. > > +              */ > > +             ++txn->n_local_rows; > >       } > > > >       try { > > The patch doesn't build on my machine. For the same reason as the > other > patch. > I suppose you'll fix that with the other patch. > > > diff --git a/test/replication-luatest/gh_6123_test.lua > b/test/replication-luatest/gh_6123_test.lua > > new file mode 100644 > > index 000000000..d0ffa0c8b > > --- /dev/null > > +++ b/test/replication-luatest/gh_6123_test.lua > > Please, find a better test name. > Like "gh_6123_truncate_temp_space_test.lua" > > @@ -0,0 +1,62 @@ > > +local fio = require('fio') > > +local log = require('log') > > +local t = require('luatest') > > +local cluster = require('test.luatest_helpers.cluster') > > +local helpers = require('test.luatest_helpers.helpers') > > + > > +local g = t.group('gh-6123') > > + > > +g.before_test('test_truncate_is_local_transaction', function() > > +    g.cluster = cluster:new({}) > > + > > +    local box_cfg = { > > +        replication         = { > > +            helpers.instance_uri('master') > > +        }, > > +        replication_timeout = 0.1, > > +        read_only           = false > > +    } > > + > > +    g.master = g.cluster:build_server({alias = 'master'}, > engine, box_cfg) > > + > > +    local box_cfg = { > > +        replication         = { > > +            helpers.instance_uri('master'), > > +            helpers.instance_uri('replica') > > +        }, > > +        replication_timeout = 0.1, > > +        replication_connect_timeout = 0.5, > > +        read_only           = true > > +    } > > + > > +    g.replica = g.cluster:build_server({alias = 'replica'}, > engine, box_cfg) > > + > > +    g.cluster:join_server(g.master) > > +    g.cluster:join_server(g.replica) > > +    g.cluster:start() > > + log.info ('Everything is started') > > +end) > > + > > +g.after_test('test_truncate_is_local_transaction', function() > > +    g.cluster:stop() > > +    fio.rmtree(g.master.workdir) > > +    fio.rmtree(g.replica.workdir) > > +end) > > + > > +g.test_truncate_is_local_transaction = function() > > +    g.master:eval("s = box.schema.space.create('temp', > {temporary = true})") > > +    g.master:eval("s:create_index('pk')") > > + > > +    g.master:eval("s:insert{1, 2}") > > +    g.master:eval("s:insert{4}") > > +    t.assert_equals(g.master:eval("return s:select()"), {{1, > 2}, {4}}) > > + > > +    g.master:eval("box.begin() > box.space._schema:replace{'smth'} s:truncate() box.commit()") > > +    t.assert_equals(g.master:eval("return s:select()"), {}) > > +    t.assert_equals(g.master:eval("return > box.space._schema:select{'smth'}"), {{'smth'}}) > > + > > +    -- Checking that replica has received the last transaction, > > +    -- and that replication isn't broken. > > +    t.assert_equals(g.replica:eval("return > box.space._schema:select{'smth'}"), {{'smth'}}) > > +    t.assert_equals(g.replica:eval("return > box.info.replication[1].upstream.status"), 'follow') > > +end > > -- > > 2.25.1 > > > > -- > Serge Petrenko > -- Serge Petrenko