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 D54096EC40; Sat, 5 Jun 2021 02:39:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D54096EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622849973; bh=N7F64hf+s9j2j9avyj+0Y1w9nUx0EefQaIotuGAYK4I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NZnfMXb5d8STqziEhYMkgJMf3moUj4Oc0w1v2ZoIM2POUvLZvlTHAB7KKvqnalxfh FFXfjV1xw8goVMSc6sAu8VsdUHJ1SyjxljgxPFbFR0E01dAUzdKBK8yX/he0NHLZjD NjMg1P0ilOfjYZ86Te1iSG9bQnX9QZxdcrEAc1pw= Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (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 84BE76EC43 for ; Sat, 5 Jun 2021 02:38:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 84BE76EC43 Received: by smtp16.mail.ru with esmtpa (envelope-from ) id 1lpJO7-0001Ge-Px; Sat, 05 Jun 2021 02:38:04 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Sat, 5 Jun 2021 01:37:57 +0200 Message-Id: X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C5423CDB5763716BB867A249A0077715520182A05F5380850406C1BA77CD662EEE8BAE807CA48476CD0D686CBD87BF0D9039F62F9EF7B5C37B1 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE765F8192D394616BAEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379C6642364E0E74208638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D88C7DE925AA0A60C910C2A845119CD5DA117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520B1593CA6EC85F86DF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C6030639D0DAF385D9735652A29929C6C4AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C37195ABA52E0305EBBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7588D3C263EAE74EA731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD775094620C760E12104256D2FEB95E1D X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC176FDF34A1E429F0A6EC7253159EABE5F3182D4F321648E9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFD99FB7B2A39B4961699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34829444FF2D8CB89B04B1F22D3D448E47FB21160AF60CD1D468E1D699B17C290E55CA398EF590D71D1D7E09C32AA3244C75E0C739C3213EC1FF22F22A8A8021F1F26BFA4C8A6946B8FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojz99asgmzejoNvvNIizHedQ== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110B8F3BE3BFF3B965087E1C440F769D3E5134DA3C03F7C870207784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 --- 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. */ -- 2.24.3 (Apple Git-128)