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 193AC6EC40; Mon, 9 Aug 2021 16:11:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 193AC6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628514665; bh=nAbh7kYj7wfMETOCeWqUhwBpQuqmteZr35Er4PgID2Q=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WuBiBdQdyu9dEW8pJMuD2ac+mzQ546f62XUi1mDbVjJKD+s1rzM4XkOrzGBDSFKqI U7jMYMxgcwUbcKdpbgWC2rBVE7JzdIa/MKPL+RExs4p8jBa+W33qr7SUQPlk92j8HD n7c/gWLLtR/kqv6z/w1X/QRexLEQ/D1t8oWGQoH8= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (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 D36656EC40 for ; Mon, 9 Aug 2021 16:11:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D36656EC40 Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1mD53X-0007Ha-3n; Mon, 09 Aug 2021 16:11:03 +0300 To: Yan Shtunder References: <20210809100931.14367-1-ya.shtunder@gmail.com> Message-ID: <43298ac3-6ae3-7a11-06ae-a978b17a12ff@tarantool.org> Date: Mon, 9 Aug 2021 16:11:02 +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: <20210809100931.14367-1-ya.shtunder@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9ECFD080E047A606F56291F8739A291D6182A05F53808504054014BD87EC6D20F509F0497A976B62C2BB2CD061026487810B3D530F129D21D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE788EDE44B2AC36D7BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371895637A5F0B45FF8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B4E251229E2D88E97F12C5672FAB0A0B117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B67FC62909E22F84089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A55D5E125CE28D5F110D55548C633BE3FF1ADEE85737611A2ED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759F66ED85EB5F25FD410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340E23B77EA18078171BF1FB892FAAF3467A00757BFB4870242DB06C5B1ABAFBE4EBA87124BC6C0D151D7E09C32AA3244C0E4DB498DC913F361D5E436AC95564904DBEAD0ED6C55A80FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojGhQhWEp1aB9x4iEvacdHiA== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A4463A7D84117A3FB75F0B168D6BCA1A724D6EC6ECFB9E3A91C1424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] replication: fill replicaset.applier.vclock after local recovery 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 09.08.2021 13:09, Yan Shtunder пишет: > 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 > --- Hi! Thanks for the fixes! LGTM. > Issue: https://github.com/tarantool/tarantool/issues/6028 > Patch: https://github.com/tarantool/tarantool/tree/yshtunder/gh-6028-applier-vclock > > src/box/applier.cc | 5 ++ > src/box/box.cc | 7 +++ > src/lib/core/errinj.h | 1 + > test/box/errinj.result | 1 + > test/replication/gh-6028-replica.lua | 13 ++++ > .../gh-6028-vclock-is-empty.result | 60 +++++++++++++++++++ > .../gh-6028-vclock-is-empty.test.lua | 24 ++++++++ > 7 files changed, 111 insertions(+) > 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-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..0b103bb6e > --- /dev/null > +++ b/test/replication/gh-6028-vclock-is-empty.result > @@ -0,0 +1,60 @@ > +-- test-run result file version 2 > +test_run = require('test_run').new() > + | --- > + | ... > + > +box.schema.user.grant('guest', 'replication') > + | --- > + | ... > +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: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..ba14eca55 > --- /dev/null > +++ b/test/replication/gh-6028-vclock-is-empty.test.lua > @@ -0,0 +1,24 @@ > +test_run = require('test_run').new() > + > +box.schema.user.grant('guest', 'replication') > +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:cmd('stop server replica') > +test_run:cmd('cleanup server replica') > +test_run:cmd('delete server replica') > -- > 2.25.1 > -- Serge Petrenko