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 BB8E96EC55; Thu, 10 Jun 2021 16:58:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BB8E96EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623333492; bh=1h/JmxqtYOMj90+W8BpgXSj5ciM7A+17KNeoE/i6jZk=; 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=g1VBi84wIyiDK/VUaSBYfyZw/TgfAGgcEGo4DVpZoq5Es5ZDhyeij5pH3QXCSiJme EGtTlz46xewcjV0qZ61627gBcQZlF6DmzhmY+p+7h2FDE+D4w8wz2awFjiqHfjIW82 yE46yblZWIZXfBmgM2UVQxnomxO42AR/AWR19gz0= Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 279B16EC55 for ; Thu, 10 Jun 2021 16:58:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 279B16EC55 Received: by smtp60.i.mail.ru with esmtpa (envelope-from ) id 1lrLCA-0003Sx-9q; Thu, 10 Jun 2021 16:58:06 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com References: Message-ID: <20ee8508-5c3b-b7e8-1ecb-5762ce974c80@tarantool.org> Date: Thu, 10 Jun 2021 16:58:05 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: ru X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C544BBC2A69B1B4100B389BF69B7A224D7C182A05F5380850403115D0C82AF6046F0CBE91C4914099A01F8572EDEA240CD31665A9009E4D9EA1 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74060EE216B493874EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378D70459430292EC88638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85C996FFE015D6A1BF938C4F3AA51ABF2117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F2CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE902A1BE408319B29287C8E22D4AE2A51D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3AD74539164518AE5040F9FF01DFDA4A8C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637A7EFCB0EB5ACB161EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A527D08A59A4ADABE591197B14387AAAED8814C1A508F279FDD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3435BBF0AC4E3A921CB60757E4BD26836C56D8B2434332EA95540CF7957EB28D6AE06F9CFCF9AC1EAD1D7E09C32AA3244C0C1742FC421A24338E6C39B6BC59B11A435BF7150578642FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojCpYK6nkTlbEEFjHp6khVPQ== X-Mailru-Sender: 583F1D7ACE8F49BD9DF7A8DAE6E2B08AA3A2A93206A5701C30ECB60673AC256F3DC58C0444729C1F424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 3/6] replication: ballot.is_loading -> is_ro 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" 05.06.2021 02:37, Vladislav Shpilevoy пишет: > Is_loading in the ballot used to mean the following: "the instance > did not finish its box.cfg() or has read_only = true". Which is > quite a strange property. > > For instance, it was 'true' even if the instance is not really > loading anymore but has read_only = true. > > The patch renames it to 'is_ro' (which existed here before, but > also with a wrong meaning). > > Its behaviour is slightly changed to report the RO state of the > instance. Not its read_only. This way it incorporates all the > possible RO conditions. Such as not finished bootstrap, having > read_only = true, being a Raft follower, and so on. > > The patch is done in scope of #5613 where the ballot is going to > be extended and used a bit differently in the join-master search > algorithm. > > Part of #5613 LGTM. > --- > src/box/box.cc | 9 +-------- > src/box/iproto_constants.h | 2 +- > src/box/replication.cc | 2 +- > src/box/xrow.c | 12 ++++++------ > src/box/xrow.h | 7 ++++--- > 5 files changed, 13 insertions(+), 19 deletions(-) > > diff --git a/src/box/box.cc b/src/box/box.cc > index d35a339ad..d56b44d33 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -2862,14 +2862,7 @@ box_process_vote(struct ballot *ballot) > { > ballot->is_ro_cfg = cfg_geti("read_only") != 0; > ballot->is_anon = replication_anon; > - /* > - * is_ro is true on initial load and is set to box.cfg.read_only > - * after box_cfg() returns, during dynamic box.cfg parameters setting. > - * We would like to prefer already bootstrapped instances to the ones > - * still bootstrapping and the ones still bootstrapping, but writeable > - * to the ones that have box.cfg.read_only = true. > - */ > - ballot->is_loading = is_ro; > + ballot->is_ro = is_ro_summary; > vclock_copy(&ballot->vclock, &replicaset.vclock); > vclock_copy(&ballot->gc_vclock, &gc.vclock); > } > diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h > index d4ee9e090..0f84843d0 100644 > --- a/src/box/iproto_constants.h > +++ b/src/box/iproto_constants.h > @@ -165,7 +165,7 @@ enum iproto_ballot_key { > IPROTO_BALLOT_IS_RO_CFG = 0x01, > IPROTO_BALLOT_VCLOCK = 0x02, > IPROTO_BALLOT_GC_VCLOCK = 0x03, > - IPROTO_BALLOT_IS_LOADING = 0x04, > + IPROTO_BALLOT_IS_RO = 0x04, > IPROTO_BALLOT_IS_ANON = 0x05, > }; > > diff --git a/src/box/replication.cc b/src/box/replication.cc > index ce2b74065..990f6239c 100644 > --- a/src/box/replication.cc > +++ b/src/box/replication.cc > @@ -987,7 +987,7 @@ replicaset_round(bool skip_ro) > * Try to find a replica which has already left > * orphan mode. > */ > - if (ballot->is_loading && !leader_ballot->is_loading) > + if (ballot->is_ro && !leader_ballot->is_ro) > continue; > /* > * Choose the replica with the most advanced > diff --git a/src/box/xrow.c b/src/box/xrow.c > index 6e2a87f8a..115a25473 100644 > --- a/src/box/xrow.c > +++ b/src/box/xrow.c > @@ -451,7 +451,7 @@ iproto_reply_vote(struct obuf *out, const struct ballot *ballot, > size_t max_size = IPROTO_HEADER_LEN + mp_sizeof_map(1) + > mp_sizeof_uint(UINT32_MAX) + mp_sizeof_map(5) + > mp_sizeof_uint(UINT32_MAX) + mp_sizeof_bool(ballot->is_ro_cfg) + > - mp_sizeof_uint(UINT32_MAX) + mp_sizeof_bool(ballot->is_loading) + > + mp_sizeof_uint(UINT32_MAX) + mp_sizeof_bool(ballot->is_ro) + > mp_sizeof_uint(IPROTO_BALLOT_IS_ANON) + > mp_sizeof_bool(ballot->is_anon) + > mp_sizeof_uint(UINT32_MAX) + > @@ -472,8 +472,8 @@ iproto_reply_vote(struct obuf *out, const struct ballot *ballot, > data = mp_encode_map(data, 5); > data = mp_encode_uint(data, IPROTO_BALLOT_IS_RO_CFG); > data = mp_encode_bool(data, ballot->is_ro_cfg); > - data = mp_encode_uint(data, IPROTO_BALLOT_IS_LOADING); > - data = mp_encode_bool(data, ballot->is_loading); > + data = mp_encode_uint(data, IPROTO_BALLOT_IS_RO); > + data = mp_encode_bool(data, ballot->is_ro); > data = mp_encode_uint(data, IPROTO_BALLOT_IS_ANON); > data = mp_encode_bool(data, ballot->is_anon); > data = mp_encode_uint(data, IPROTO_BALLOT_VCLOCK); > @@ -1358,7 +1358,7 @@ int > xrow_decode_ballot(struct xrow_header *row, struct ballot *ballot) > { > ballot->is_ro_cfg = false; > - ballot->is_loading = false; > + ballot->is_ro = false; > ballot->is_anon = false; > vclock_create(&ballot->vclock); > > @@ -1404,10 +1404,10 @@ xrow_decode_ballot(struct xrow_header *row, struct ballot *ballot) > goto err; > ballot->is_ro_cfg = mp_decode_bool(&data); > break; > - case IPROTO_BALLOT_IS_LOADING: > + case IPROTO_BALLOT_IS_RO: > if (mp_typeof(*data) != MP_BOOL) > goto err; > - ballot->is_loading = mp_decode_bool(&data); > + ballot->is_ro = mp_decode_bool(&data); > break; > case IPROTO_BALLOT_IS_ANON: > if (mp_typeof(*data) != MP_BOOL) > diff --git a/src/box/xrow.h b/src/box/xrow.h > index 241a7af8e..1d00b2e43 100644 > --- a/src/box/xrow.h > +++ b/src/box/xrow.h > @@ -374,10 +374,11 @@ struct ballot { > */ > bool is_anon; > /** > - * Set if the instance hasn't finished bootstrap or recovery, or > - * is syncing with other replicas in the replicaset. > + * Set if the instance is not writable due to any reason. Could be > + * config read_only=true; being orphan; being a Raft follower; not > + * finished recovery/bootstrap; or anything else. > */ > - bool is_loading; > + bool is_ro; > /** Current instance vclock. */ > struct vclock vclock; > /** Oldest vclock available on the instance. */ -- Serge Petrenko