Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org, gorcunov@gmail.com
Subject: Re: [Tarantool-patches] [PATCH 06/12] raft: make raft_request.vclock constant
Date: Tue, 17 Nov 2020 12:17:50 +0300	[thread overview]
Message-ID: <8dbd1ccd-738a-d7c1-a916-90468309faab@tarantool.org> (raw)
In-Reply-To: <f26ce6ea2c237e1cfaef306a75706bd85042f748.1605570907.git.v.shpilevoy@tarantool.org>


17.11.2020 03:02, Vladislav Shpilevoy пишет:
> Raft is never supposed to change vclock. Not the stored one, nor
> the received ones. The patch makes it checked during compilation.
>
> The patch is mostly motivated by a next patch making Raft use an
> externally configured vclock which can't be changed. Since Raft
> uses raft_request to carry the vclock in a few places, the
> request's vclock also must become const.
>
> Part of #5303


LGTM.


> ---
>   src/box/box.cc    | 2 +-
>   src/box/raftlib.c | 9 +++------
>   src/box/raftlib.h | 3 +--
>   src/box/xrow.c    | 2 +-
>   src/box/xrow.h    | 2 +-
>   5 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 8f5f3558e..78fca928e 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -2142,7 +2142,7 @@ box_process_subscribe(struct ev_io *io, struct xrow_header *header)
>   		 * should be 0.
>   		 */
>   		struct raft_request req;
> -		raft_serialize_for_network(box_raft(), &req, &vclock);
> +		raft_serialize_for_network(box_raft(), &req);
>   		xrow_encode_raft(&row, &fiber()->gc, &req);
>   		coio_write_xrow(io, &row);
>   	}
> diff --git a/src/box/raftlib.c b/src/box/raftlib.c
> index ca1940ba6..78164bf91 100644
> --- a/src/box/raftlib.c
> +++ b/src/box/raftlib.c
> @@ -850,8 +850,7 @@ raft_sm_stop(struct raft *raft)
>   }
>   
>   void
> -raft_serialize_for_network(const struct raft *raft, struct raft_request *req,
> -			   struct vclock *vclock)
> +raft_serialize_for_network(const struct raft *raft, struct raft_request *req)
>   {
>   	memset(req, 0, sizeof(*req));
>   	/*
> @@ -865,10 +864,8 @@ raft_serialize_for_network(const struct raft *raft, struct raft_request *req,
>   	 * Raft does not own vclock, so it always expects it passed externally.
>   	 * Vclock is sent out only by candidate instances.
>   	 */
> -	if (req->state == RAFT_STATE_CANDIDATE) {
> -		req->vclock = vclock;
> -		vclock_copy(vclock, &replicaset.vclock);
> -	}
> +	if (req->state == RAFT_STATE_CANDIDATE)
> +		req->vclock = &replicaset.vclock;
>   }
>   
>   void
> diff --git a/src/box/raftlib.h b/src/box/raftlib.h
> index f75ed2567..2da3cec86 100644
> --- a/src/box/raftlib.h
> +++ b/src/box/raftlib.h
> @@ -263,8 +263,7 @@ raft_new_term(struct raft *raft);
>    * cluster. It is allowed to save anything here, not only persistent state.
>    */
>   void
> -raft_serialize_for_network(const struct raft *raft, struct raft_request *req,
> -			   struct vclock *vclock);
> +raft_serialize_for_network(const struct raft *raft, struct raft_request *req);
>   
>   /**
>    * Save complete Raft state into a request to be persisted on disk. Only term
> diff --git a/src/box/xrow.c b/src/box/xrow.c
> index 165a00a16..bc06738ad 100644
> --- a/src/box/xrow.c
> +++ b/src/box/xrow.c
> @@ -1057,7 +1057,7 @@ xrow_decode_raft(const struct xrow_header *row, struct raft_request *r,
>   			r->vclock = vclock;
>   			if (r->vclock == NULL)
>   				mp_next(&pos);
> -			else if (mp_decode_vclock_ignore0(&pos, r->vclock) != 0)
> +			else if (mp_decode_vclock_ignore0(&pos, vclock) != 0)
>   				goto bad_msgpack;
>   			break;
>   		default:
> diff --git a/src/box/xrow.h b/src/box/xrow.h
> index 095911239..3d68c1268 100644
> --- a/src/box/xrow.h
> +++ b/src/box/xrow.h
> @@ -268,7 +268,7 @@ struct raft_request {
>   	uint64_t term;
>   	uint32_t vote;
>   	uint32_t state;
> -	struct vclock *vclock;
> +	const struct vclock *vclock;
>   };
>   
>   int

-- 
Serge Petrenko

  reply	other threads:[~2020-11-17  9:17 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17  0:02 [Tarantool-patches] [PATCH 00/12] Raft module, part 2 - relocation to src/lib/raft Vladislav Shpilevoy
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 01/12] raft: move sources to raftlib.h/.c Vladislav Shpilevoy
2020-11-17  8:14   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 10/12] raft: move box_update_ro_summary to update trigger Vladislav Shpilevoy
2020-11-17 12:42   ` Serge Petrenko
2020-11-17 15:17     ` Serge Petrenko
2020-11-18 23:21     ` Vladislav Shpilevoy
2020-11-19 10:08       ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 11/12] raft: introduce RaftError Vladislav Shpilevoy
2020-11-17 15:13   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 12/12] raft: move algorithm code to src/lib/raft Vladislav Shpilevoy
2020-11-17 15:13   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 02/12] raft: move box_raft_* to src/box/raft.h and .c Vladislav Shpilevoy
2020-11-17  8:14   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 03/12] raft: stop using replication_disconnect_timeout() Vladislav Shpilevoy
2020-11-17  8:15   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 04/12] raft: stop using replication_synchro_quorum Vladislav Shpilevoy
2020-11-17  8:17   ` Serge Petrenko
2020-11-19 23:42     ` Vladislav Shpilevoy
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 05/12] raft: stop using instance_id Vladislav Shpilevoy
2020-11-17  8:59   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 06/12] raft: make raft_request.vclock constant Vladislav Shpilevoy
2020-11-17  9:17   ` Serge Petrenko [this message]
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 07/12] raft: stop using replicaset.vclock Vladislav Shpilevoy
2020-11-17  9:23   ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 08/12] raft: introduce vtab for disk and network Vladislav Shpilevoy
2020-11-17  9:35   ` Serge Petrenko
2020-11-19 23:43     ` Vladislav Shpilevoy
2020-11-17 10:00   ` Serge Petrenko
2020-11-19 23:43     ` Vladislav Shpilevoy
2020-11-20  7:56       ` Serge Petrenko
2020-11-20 19:40         ` Vladislav Shpilevoy
2020-11-23  8:09           ` Serge Petrenko
2020-11-17  0:02 ` [Tarantool-patches] [PATCH 09/12] raft: introduce raft_msg, drop xrow dependency Vladislav Shpilevoy
2020-11-17 10:22   ` Serge Petrenko
2020-11-19 23:43     ` Vladislav Shpilevoy
2020-11-20  8:03       ` Serge Petrenko

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=8dbd1ccd-738a-d7c1-a916-90468309faab@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 06/12] raft: make raft_request.vclock constant' \
    /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