Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com,
	sergepetrenko@tarantool.org
Subject: [Tarantool-patches] [PATCH 2/6] replication: ballot.is_ro -> is_ro_cfg
Date: Sat,  5 Jun 2021 01:37:56 +0200
Message-ID: <cc2f9823ee890a2dbd89891a744fa6ef12899885.1622849790.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1622849790.git.v.shpilevoy@tarantool.org>

Rename the member to show its actual meaning. It is not the
real RO state of the instance. Only how it is configured.

It can happen that the instance is read_only = false, but still is
in RO state due to other reasons.

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             |  2 +-
 src/box/iproto_constants.h |  2 +-
 src/box/replication.cc     |  2 +-
 src/box/xrow.c             | 12 ++++++------
 src/box/xrow.h             |  4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index 0e615e944..d35a339ad 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -2860,7 +2860,7 @@ box_process_subscribe(struct ev_io *io, struct xrow_header *header)
 void
 box_process_vote(struct ballot *ballot)
 {
-	ballot->is_ro = cfg_geti("read_only") != 0;
+	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
diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index 7362ddaf1..d4ee9e090 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -162,7 +162,7 @@ enum iproto_metadata_key {
 };
 
 enum iproto_ballot_key {
-	IPROTO_BALLOT_IS_RO = 0x01,
+	IPROTO_BALLOT_IS_RO_CFG = 0x01,
 	IPROTO_BALLOT_VCLOCK = 0x02,
 	IPROTO_BALLOT_GC_VCLOCK = 0x03,
 	IPROTO_BALLOT_IS_LOADING = 0x04,
diff --git a/src/box/replication.cc b/src/box/replication.cc
index a1c6e3c7c..ce2b74065 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -976,7 +976,7 @@ replicaset_round(bool skip_ro)
 		 * replicas since there is still a possibility
 		 * that all replicas exist in cluster table.
 		 */
-		if (skip_ro && ballot->is_ro)
+		if (skip_ro && ballot->is_ro_cfg)
 			continue;
 		if (leader == NULL) {
 			leader = replica;
diff --git a/src/box/xrow.c b/src/box/xrow.c
index 2e364cea5..6e2a87f8a 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -450,7 +450,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) +
+		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(IPROTO_BALLOT_IS_ANON) +
 		mp_sizeof_bool(ballot->is_anon) +
@@ -470,8 +470,8 @@ iproto_reply_vote(struct obuf *out, const struct ballot *ballot,
 	data = mp_encode_map(data, 1);
 	data = mp_encode_uint(data, IPROTO_BALLOT);
 	data = mp_encode_map(data, 5);
-	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_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_ANON);
@@ -1357,7 +1357,7 @@ xrow_encode_vote(struct xrow_header *row)
 int
 xrow_decode_ballot(struct xrow_header *row, struct ballot *ballot)
 {
-	ballot->is_ro = false;
+	ballot->is_ro_cfg = false;
 	ballot->is_loading = false;
 	ballot->is_anon = false;
 	vclock_create(&ballot->vclock);
@@ -1399,10 +1399,10 @@ xrow_decode_ballot(struct xrow_header *row, struct ballot *ballot)
 		}
 		uint32_t key = mp_decode_uint(&data);
 		switch (key) {
-		case IPROTO_BALLOT_IS_RO:
+		case IPROTO_BALLOT_IS_RO_CFG:
 			if (mp_typeof(*data) != MP_BOOL)
 				goto err;
-			ballot->is_ro = mp_decode_bool(&data);
+			ballot->is_ro_cfg = mp_decode_bool(&data);
 			break;
 		case IPROTO_BALLOT_IS_LOADING:
 			if (mp_typeof(*data) != MP_BOOL)
diff --git a/src/box/xrow.h b/src/box/xrow.h
index b3c664be2..241a7af8e 100644
--- a/src/box/xrow.h
+++ b/src/box/xrow.h
@@ -366,8 +366,8 @@ xrow_encode_auth(struct xrow_header *row, const char *salt, size_t salt_len,
 
 /** Reply to IPROTO_VOTE request. */
 struct ballot {
-	/** Set if the instance is running in read-only mode. */
-	bool is_ro;
+	/** Set if the instance is configured in read-only mode. */
+	bool is_ro_cfg;
 	/**
 	 * A flag whether the instance is anonymous, not having an
 	 * ID, and not going to request it.
-- 
2.24.3 (Apple Git-128)


  parent reply	other threads:[~2021-06-04 23:39 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 ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-06-10 13:56   ` [Tarantool-patches] [PATCH 2/6] replication: ballot.is_ro -> is_ro_cfg 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
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=cc2f9823ee890a2dbd89891a744fa6ef12899885.1622849790.git.v.shpilevoy@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