Skip to content

Commit

Permalink
replication: ballot.is_ro -> is_ro_cfg
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gerold103 committed Jun 4, 2021
1 parent 751c136 commit cc2f982
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/box/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/box/iproto_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/box/replication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/box/xrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/box/xrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cc2f982

Please sign in to comment.