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 E719E6EC40; Sat, 5 Jun 2021 02:40:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E719E6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622850004; bh=ZLlxyXb4XJ3cpLdqJv0MANXXHLBHwgUrrLWRu1mvKtw=; 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=AUzs2PLCKNL/r6/BUZ+q6yC2B1Qb7r3an970rTHuV+r5iTDImkphPGAmalkpd3xlI ijYe1gKKQfuYZ2eLUy7QZJTg++/GLTHgBBEn7DV9CA/tgIB2m9ln5+fLRHRlbOFX1i hx4kfdFYuxFtEBvA9GBqoGLysVlgNQBtd2ZmwCNk= 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 6DE7F6EC5B for ; Sat, 5 Jun 2021 02:38:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6DE7F6EC5B Received: by smtp16.mail.ru with esmtpa (envelope-from ) id 1lpJO8-0001Ge-JH; Sat, 05 Jun 2021 02:38:05 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Sat, 5 Jun 2021 01:37:58 +0200 Message-Id: <571f31727582463f25f490c41c095199ea88da3a.1622849790.git.v.shpilevoy@tarantool.org> 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: 4F1203BC0FB41BD9D5B0DA836B685C546075B3437CB362FF47FF2EE3FBA69D6F182A05F5380850404794E587DD25C9B8171751256CBD6C563E8439662D9467D704EFD275A3A55D2D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE777EC2A23A44B1FFFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378F586D843116CFB2EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BD6CF32B5F8F9D404DD5FB105667B6BA454CB4AB22087F431CC7F00164DA146DAFE8445B8C89999728AA50765F790063773DCDF0198120BE8389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC897AD43380FEE24CAF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C241FAFF9BB01F7E7AD7EC71F1DB884274AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C3F035437B6AEB70F476E601842F6C81A1F004C906525384307823802FF610243DF43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CFA80D66F452D417A43847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD775094620C760E121C7FEFD6F2AD59F7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CC176FDF34A1E429FDABE55907F9942E8C3D6435D6F802BC69C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFD99FB7B2A39B4961699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347D10A9FCB2A62DFE5A00D7BEDE863C778F5368113EDF92C4C748487B14DD110A924367A914CD8F281D7E09C32AA3244CBA19603532E40F28E266AA14D3D1A50F3A92A9747B6CC886FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojz99asgmzejoGk7vwq0FQ9Q== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110B8F3BE3BFF3B96508DEDE22214A0719F4725A2E8059E754E07784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 4/6] replication: introduce ballot.is_booted 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" The new field reports whether the instance has finished its bootstrap/recovery, or IOW has finished box.cfg(). The new field will help in fixing #5613 so as not to try to join to a replicaset via non-bootstrapped instances if there are others. The problem is that otherwise, if all nodes are booted but are read-only, new instances bootstrap their own independent replicaset. It would be better to just fail and terminate the process than do such a bizarre action. Part of #5613 --- src/box/box.cc | 1 + src/box/iproto_constants.h | 1 + src/box/xrow.c | 14 ++++++++++++-- src/box/xrow.h | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index d56b44d33..6fca337bc 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -2863,6 +2863,7 @@ box_process_vote(struct ballot *ballot) ballot->is_ro_cfg = cfg_geti("read_only") != 0; ballot->is_anon = replication_anon; ballot->is_ro = is_ro_summary; + ballot->is_booted = is_box_configured; 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 0f84843d0..137bee9da 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -167,6 +167,7 @@ enum iproto_ballot_key { IPROTO_BALLOT_GC_VCLOCK = 0x03, IPROTO_BALLOT_IS_RO = 0x04, IPROTO_BALLOT_IS_ANON = 0x05, + IPROTO_BALLOT_IS_BOOTED = 0x06, }; #define bit(c) (1ULL<is_ro_cfg) + 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(IPROTO_BALLOT_IS_BOOTED) + + mp_sizeof_bool(ballot->is_booted) + mp_sizeof_uint(UINT32_MAX) + mp_sizeof_vclock_ignore0(&ballot->vclock) + mp_sizeof_uint(UINT32_MAX) + @@ -469,13 +471,15 @@ iproto_reply_vote(struct obuf *out, const struct ballot *ballot, char *data = buf + IPROTO_HEADER_LEN; data = mp_encode_map(data, 1); data = mp_encode_uint(data, IPROTO_BALLOT); - data = mp_encode_map(data, 5); + data = mp_encode_map(data, 6); 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_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_IS_BOOTED); + data = mp_encode_bool(data, ballot->is_booted); data = mp_encode_uint(data, IPROTO_BALLOT_VCLOCK); data = mp_encode_vclock_ignore0(data, &ballot->vclock); data = mp_encode_uint(data, IPROTO_BALLOT_GC_VCLOCK); @@ -1360,6 +1364,7 @@ xrow_decode_ballot(struct xrow_header *row, struct ballot *ballot) ballot->is_ro_cfg = false; ballot->is_ro = false; ballot->is_anon = false; + ballot->is_booted = true; vclock_create(&ballot->vclock); const char *start = NULL; @@ -1424,6 +1429,11 @@ xrow_decode_ballot(struct xrow_header *row, struct ballot *ballot) &ballot->gc_vclock) != 0) goto err; break; + case IPROTO_BALLOT_IS_BOOTED: + if (mp_typeof(*data) != MP_BOOL) + goto err; + ballot->is_booted = mp_decode_bool(&data); + break; default: mp_next(&data); } diff --git a/src/box/xrow.h b/src/box/xrow.h index 1d00b2e43..055fd31e1 100644 --- a/src/box/xrow.h +++ b/src/box/xrow.h @@ -379,6 +379,8 @@ struct ballot { * finished recovery/bootstrap; or anything else. */ bool is_ro; + /** Set if the instance has finished its bootstrap/recovery. */ + bool is_booted; /** Current instance vclock. */ struct vclock vclock; /** Oldest vclock available on the instance. */ -- 2.24.3 (Apple Git-128)