Tarantool development patches archive
 help / color / mirror / Atom feed
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 3/6] replication: ballot.is_loading -> is_ro
Date: Thu, 10 Jun 2021 16:58:05 +0300
Message-ID: <20ee8508-5c3b-b7e8-1ecb-5762ce974c80@tarantool.org> (raw)
In-Reply-To: <af1fde986af78eb919df83f172eaf401697355cf.1622849790.git.v.shpilevoy@tarantool.org>



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


  reply	other threads:[~2021-06-10 13:58 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 [this message]
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
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=20ee8508-5c3b-b7e8-1ecb-5762ce974c80@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    /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

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git