[Tarantool-patches] [PATCH 2/6] replication: ballot.is_ro -> is_ro_cfg

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Jun 5 02:37:56 MSK 2021


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)



More information about the Tarantool-patches mailing list