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 6A6D77118D; Mon, 25 Oct 2021 16:34:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6A6D77118D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635168864; bh=cstSCnU4XpGB7zV+ON2XQ+upfJxKT7Wx3nEMCh0FEj0=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QGGhbRbWMxHcXYyBBiphQ30QKdxEU6ku0hMpiJ0x0LX8Ei4Av21HJgAll8mqNvpps ULJMaByb9ePxgWuk5F8EMtlUXBUXGq+w+KrR7KfNFi9jXWaBvGxpJLb/R6FQYkaqkG m6HvFGirDtT50RM/PDSNh60ycmSQY9EoQe86OVcU= Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 56E717118D for ; Mon, 25 Oct 2021 16:34:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 56E717118D Received: by smtp50.i.mail.ru with esmtpa (envelope-from ) id 1mf07K-0005l5-Pf; Mon, 25 Oct 2021 16:34:23 +0300 To: Yan Shtunder , tarantool-patches@dev.tarantool.org References: <20211025104449.26693-1-ya.shtunder@gmail.com> Message-ID: Date: Mon, 25 Oct 2021 16:34:22 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211025104449.26693-1-ya.shtunder@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: ru X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D1D35DBD2D15487E109F535F427989191BFAC4E9BCE66C72182A05F538085040B5FEB3755B4BDC4EA8FBDE14DEF575A06C8CB8F0D411CB3123F7C9643F759C03 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FBB2043146276655EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DDCE02C19EA0BA868638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A8925A6DD1D97D3864875BB29B57BAB4117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD186FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6D635BA3ABDB36C18089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5080E15A4F2E3A8E57182DB299804E68F3A8723C60A9E2BFED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FA7FF33AA1A4D21C410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34060C3C6DE316ECE4AACB64C14C9AD076C9896358486DBF973E33580FA64ABA27FE1C30B21763DCE91D7E09C32AA3244CC7C34DCF6145517388B36B16E866E9061DD47778AE04E04D729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojPL6H901iH3F061yHVJffKw== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A44661832C9C5EC03E2F419650E99C3AF6C7F98C081CED148BAF424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 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" 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