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 325726EC40; Mon, 9 Aug 2021 10:09:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 325726EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628492966; bh=A/V5O/21/nZ8PlSuLTENEV8agGhFdPvWD2FR6y/MGx0=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Zx+4PzThhm/HxG/7Jka8JnRpY4qULog0yt72CjpkcT3kl/ZHbnFE8HWKjK2Nwtl1S WeAkDGjZjkYjw/qrRjs7cZZljqEQ9M13oKjpTXgrWDxsezHDkYUe+bjmJJDtWeCu9K pX7Dkb/vlAsplUS71kM1QADu3xCWYl8rZ+rylsOg= Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 3B14C6EC40 for ; Mon, 9 Aug 2021 10:09:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3B14C6EC40 Received: by smtp52.i.mail.ru with esmtpa (envelope-from ) id 1mCzPY-0005RJ-J3; Mon, 09 Aug 2021 10:09:25 +0300 To: Yan Shtunder Cc: tarantool-patches@dev.tarantool.org References: <20210806015607.14898-1-ya.shtunder@gmail.com> Message-ID: Date: Mon, 9 Aug 2021 10:09:24 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210806015607.14898-1-ya.shtunder@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9ECFD080E047A606F6525B29142351271182A05F538085040C7B0223C650995FB1659D892B1D8F5B24837DF3669EFD31B7C9E68DD7FFB4200 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74060EE216B493874EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376DFCC587F0A0398D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8883B5964C55F71AA6460ABC45CED5D77117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6ACE00135B021D8CA089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A51D0EB0FA8E4E7264AD785590D1FD5CF24A19BA78DEFD3FB7D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75AF0B556A5A327A45410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3463DBE2ADA183F62FD95838D41633E367BC551F84767008C89858EA869FC368831AAA5330E485345C1D7E09C32AA3244CE696156C7426ED7394315058BA7C5B6C6C24832127668422729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMTMPlNJj3ShKo3tIz0Gzxw== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A44615C42DB8C6EC5F1B9784E4D08BE597DB3E7CFFCDDAF2340F424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] (no subject) 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" Hi! Thanks for the patch! Please, find 5 comments below. 06.08.2021 04:56, Yan Shtunder пишет: > Issue: https://github.com/tarantool/tarantool/issues/6028 > Patch: https://github.com/tarantool/tarantool/tree/yshtunder/gh-6028-applier-vclock 1. Please put issue and branch links lower, below the "---".    Otherwise git-send-email has a hard time finding the letter subject.    That's why this letter has an empty subject. > Subject: [PATCH] replication: fill replicaset.applier.vclock after local > recovery > > replicaset.applier.vclock is initialized in replication_init(), which happens before local recovery.If some changes are come frome some instance via applier that applier.vclock will equal 0.This means that if some wild master send this node already applied data, the node will apply the same data twice. > > Closes #6028 2. Please wrap commit message lines at about 70-75 characters.    Otherwise such a long line looks bad when you do `git log`. > --- > src/box/applier.cc | 5 ++ > src/box/box.cc | 7 ++ > src/lib/core/errinj.h | 1 + > test/box/errinj.result | 1 + > ...0-misc-heartbeats-on-master-changes.result | 2 +- > test/replication/gh-6028-replica.lua | 13 ++++ > .../gh-6028-vclock-is-empty.result | 65 +++++++++++++++++++ > .../gh-6028-vclock-is-empty.test.lua | 26 ++++++++ > 8 files changed, 119 insertions(+), 1 deletion(-) > create mode 100644 test/replication/gh-6028-replica.lua > create mode 100644 test/replication/gh-6028-vclock-is-empty.result > create mode 100644 test/replication/gh-6028-vclock-is-empty.test.lua > > diff --git a/src/box/applier.cc b/src/box/applier.cc > index 07fe7f5c7..9855b8d37 100644 > --- a/src/box/applier.cc > +++ b/src/box/applier.cc > @@ -1230,6 +1230,11 @@ applier_subscribe(struct applier *applier) > struct vclock vclock; > vclock_create(&vclock); > vclock_copy(&vclock, &replicaset.vclock); > + > + ERROR_INJECT(ERRINJ_REPLICASET_VCLOCK, { > + vclock_create(&vclock); > + }); > + > /* > * Stop accepting local rows coming from a remote > * instance as soon as local WAL starts accepting writes. > diff --git a/src/box/box.cc b/src/box/box.cc > index ab7d983c9..f5cd63c9e 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -3451,6 +3451,13 @@ box_cfg_xc(void) > bootstrap(&instance_uuid, &replicaset_uuid, > &is_bootstrap_leader); > } > + > + /* > + * replicaset.applier.vclock is filled with real > + * value where local restore has already completed > + */ > + vclock_copy(&replicaset.applier.vclock, &replicaset.vclock); > + > fiber_gc(); > > /* > diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h > index 359174b16..fcd856fbb 100644 > --- a/src/lib/core/errinj.h > +++ b/src/lib/core/errinj.h > @@ -152,6 +152,7 @@ struct errinj { > _(ERRINJ_STDIN_ISATTY, ERRINJ_INT, {.iparam = -1}) \ > _(ERRINJ_SNAP_COMMIT_FAIL, ERRINJ_BOOL, {.bparam = false}) \ > _(ERRINJ_IPROTO_SINGLE_THREAD_STAT, ERRINJ_INT, {.iparam = -1}) \ > + _(ERRINJ_REPLICASET_VCLOCK, ERRINJ_BOOL, {.bparam = false}) \ > > ENUM0(errinj_id, ERRINJ_LIST); > extern struct errinj errinjs[]; > diff --git a/test/box/errinj.result b/test/box/errinj.result > index 43daf5f0f..62e37bbdd 100644 > --- a/test/box/errinj.result > +++ b/test/box/errinj.result > @@ -70,6 +70,7 @@ evals > - ERRINJ_RELAY_REPORT_INTERVAL: 0 > - ERRINJ_RELAY_SEND_DELAY: false > - ERRINJ_RELAY_TIMEOUT: 0 > + - ERRINJ_REPLICASET_VCLOCK: false > - ERRINJ_REPLICA_JOIN_DELAY: false > - ERRINJ_SIO_READ_MAX: -1 > - ERRINJ_SNAP_COMMIT_DELAY: false > diff --git a/test/replication/gh-3160-misc-heartbeats-on-master-changes.result b/test/replication/gh-3160-misc-heartbeats-on-master-changes.result > index 86e5ddfa0..f5ffbe17d 100644 > --- a/test/replication/gh-3160-misc-heartbeats-on-master-changes.result > +++ b/test/replication/gh-3160-misc-heartbeats-on-master-changes.result > @@ -57,7 +57,7 @@ test_run:cmd("setopt delimiter ''"); > ... > test_timeout() > --- > -- true > +- false > ... > test_run:cmd("switch default") > --- 3. ^ this is an extraneous change. Please, remove it. > diff --git a/test/replication/gh-6028-replica.lua b/test/replication/gh-6028-replica.lua > new file mode 100644 > index 000000000..5669cc4e9 > --- /dev/null > +++ b/test/replication/gh-6028-replica.lua > @@ -0,0 +1,13 @@ > +#!/usr/bin/env tarantool > + > +require('console').listen(os.getenv('ADMIN')) > + > +box.error.injection.set("ERRINJ_REPLICASET_VCLOCK", true) > + > +box.cfg({ > + listen = os.getenv("LISTEN"), > + replication = {os.getenv("MASTER"), os.getenv("LISTEN")}, > + memtx_memory = 107374182, > +}) > + > +box.error.injection.set("ERRINJ_REPLICASET_VCLOCK", false) > diff --git a/test/replication/gh-6028-vclock-is-empty.result b/test/replication/gh-6028-vclock-is-empty.result > new file mode 100644 > index 000000000..944c0905e > --- /dev/null > +++ b/test/replication/gh-6028-vclock-is-empty.result > @@ -0,0 +1,65 @@ > +-- test-run result file version 2 > +test_run = require('test_run').new() > + | --- > + | ... > + > + > +box.schema.user.grant('guest', 'super') > + | --- > + | ... 4. `box.schema.user.grant('guest', 'replication')` would be enough here.    Better not grant more privileges than really needed. > +s = box.schema.create_space('test') > + | --- > + | ... > +_ = s:create_index('pk') > + | --- > + | ... > + > + > +-- Case 1 > +test_run:cmd('create server replica with rpl_master=default,\ > + script="replication/gh-6028-replica.lua"') > + | --- > + | - true > + | ... > +test_run:cmd('start server replica') > + | --- > + | - true > + | ... > + > +test_run:cmd('stop server replica') > + | --- > + | - true > + | ... > +s:insert{1} > + | --- > + | - [1] > + | ... > + > + > +-- Case 2 > +test_run:cmd('start server replica') > + | --- > + | - true > + | ... > +s:insert{2} > + | --- > + | - [2] > + | ... > + > + > +test_run:switch('default') > + | --- > + | - true > + | ... 5. You're already on 'default' instance. No need to switch again. > +test_run:cmd('stop server replica') > + | --- > + | - true > + | ... > +test_run:cmd('cleanup server replica') > + | --- > + | - true > + | ... > +test_run:cmd('delete server replica') > + | --- > + | - true > + | ... > diff --git a/test/replication/gh-6028-vclock-is-empty.test.lua b/test/replication/gh-6028-vclock-is-empty.test.lua > new file mode 100644 > index 000000000..e981958b2 > --- /dev/null > +++ b/test/replication/gh-6028-vclock-is-empty.test.lua > @@ -0,0 +1,26 @@ > +test_run = require('test_run').new() > + > + > +box.schema.user.grant('guest', 'super') > +s = box.schema.create_space('test') > +_ = s:create_index('pk') > + > + > +-- Case 1 > +test_run:cmd('create server replica with rpl_master=default,\ > + script="replication/gh-6028-replica.lua"') > +test_run:cmd('start server replica') > + > +test_run:cmd('stop server replica') > +s:insert{1} > + > + > +-- Case 2 > +test_run:cmd('start server replica') > +s:insert{2} > + > + > +test_run:switch('default') > +test_run:cmd('stop server replica') > +test_run:cmd('cleanup server replica') > +test_run:cmd('delete server replica') > -- > 2.25.1 > -- Serge Petrenko