From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>, tarantool-patches@dev.tarantool.org, gorcunov@gmail.com Subject: Re: [Tarantool-patches] [PATCH 4/6] replication: introduce ballot.is_booted Date: Thu, 10 Jun 2021 17:02:04 +0300 [thread overview] Message-ID: <3d9994a9-01a1-6fbb-ad7e-5e651189a357@tarantool.org> (raw) In-Reply-To: <571f31727582463f25f490c41c095199ea88da3a.1622849790.git.v.shpilevoy@tarantool.org> 05.06.2021 02:37, Vladislav Shpilevoy пишет: > 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 Thanks! LGTM. > --- > 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<<IPROTO_##c) > diff --git a/src/box/xrow.c b/src/box/xrow.c > index 115a25473..0d0548fef 100644 > --- a/src/box/xrow.c > +++ b/src/box/xrow.c > @@ -449,11 +449,13 @@ iproto_reply_vote(struct obuf *out, const struct ballot *ballot, > uint64_t sync, uint32_t schema_version) > { > 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_map(6) + > mp_sizeof_uint(UINT32_MAX) + mp_sizeof_bool(ballot->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. */ -- Serge Petrenko
next prev parent reply other threads:[~2021-06-10 14:02 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-04 23:37 [Tarantool-patches] [PATCH 0/6] Instance join should prefer booted instances Vladislav Shpilevoy via Tarantool-patches 2021-06-04 23:37 ` [Tarantool-patches] [PATCH 1/6] replication: refactor replicaset_leader() Vladislav Shpilevoy via Tarantool-patches 2021-06-10 13:54 ` Serge Petrenko via Tarantool-patches 2021-06-04 23:37 ` [Tarantool-patches] [PATCH 2/6] replication: ballot.is_ro -> is_ro_cfg Vladislav Shpilevoy via Tarantool-patches 2021-06-10 13:56 ` Serge Petrenko via Tarantool-patches 2021-06-04 23:37 ` [Tarantool-patches] [PATCH 3/6] replication: ballot.is_loading -> is_ro Vladislav Shpilevoy via Tarantool-patches 2021-06-10 13:58 ` Serge Petrenko via Tarantool-patches 2021-06-04 23:37 ` [Tarantool-patches] [PATCH 4/6] replication: introduce ballot.is_booted Vladislav Shpilevoy via Tarantool-patches 2021-06-10 14:02 ` Serge Petrenko via Tarantool-patches [this message] 2021-06-04 23:37 ` [Tarantool-patches] [PATCH 5/6] replication: use 'score' to find a join-master Vladislav Shpilevoy via Tarantool-patches 2021-06-10 14:06 ` Serge Petrenko via Tarantool-patches 2021-06-10 15:02 ` Cyrill Gorcunov via Tarantool-patches 2021-06-10 20:09 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-10 21:28 ` Cyrill Gorcunov via Tarantool-patches 2021-06-04 23:38 ` [Tarantool-patches] [PATCH 6/6] replication: prefer to join from booted replicas Vladislav Shpilevoy via Tarantool-patches 2021-06-06 17:06 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-10 14:14 ` Serge Petrenko via Tarantool-patches 2021-06-06 17:03 ` [Tarantool-patches] [PATCH 7/6] raft: test join to a raft cluster Vladislav Shpilevoy via Tarantool-patches 2021-06-06 23:01 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-10 14:17 ` Serge Petrenko via Tarantool-patches 2021-06-10 15:03 ` [Tarantool-patches] [PATCH 0/6] Instance join should prefer booted instances Cyrill Gorcunov via Tarantool-patches 2021-06-11 20:56 ` Vladislav Shpilevoy via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=3d9994a9-01a1-6fbb-ad7e-5e651189a357@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 4/6] replication: introduce ballot.is_booted' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox