[Tarantool-patches] [PATCH v2 09/11] raft: introduce state machine
Serge Petrenko
sergepetrenko at tarantool.org
Tue Sep 22 11:49:34 MSK 2020
22.09.2020 01:47, Vladislav Shpilevoy пишет:
> My new changes for this commit, on top of the branch:
>
> ====================
> [tosquash] raft: don't broadcast shit from WAL writer; add a log;
>
> raft_write_request() should not broadcast anything.
>
> 1. It is a WAL write function, has nothing to do with talking to
> other nodes.
>
> 2. Its caller, raft_worker_handle_io(), already does the
> broadcast.
>
> 3. Broadcast was done wrong - it didn't send vclock when vote
> was == instance_id. Led to warnings about missing vclock.
>
> Also a new log was added for the skipped RAFT messages. Not to
> loose anything. Anyway the messages are rare. 99% of the RAFT
> interaction will be via empty heartbeats. So it makes sense to
> log everything happening in the rest of the time.
>
> diff --git a/src/box/raft.c b/src/box/raft.c
> index 237d71a2d..f712887a1 100644
> --- a/src/box/raft.c
> +++ b/src/box/raft.c
> @@ -332,8 +332,11 @@ raft_process_msg(const struct raft_request *req, uint32_t source)
> assert(source > 0);
> assert(source != instance_id);
> /* Outdated request. */
> - if (req->term < raft.volatile_term)
> + if (req->term < raft.volatile_term) {
> + say_info("RAFT: the message is ignored due to outdated term - "
> + "current term is %u", raft.volatile_term);
> return;
> + }
>
> enum raft_state old_state = raft.state;
>
> @@ -545,8 +548,6 @@ raft_write_request(const struct raft_request *req)
> goto fail;
> }
>
> - raft_broadcast(req);
> -
> region_truncate(region, svp);
> return;
> fail:
Looking good
--
Serge Petrenko
More information about the Tarantool-patches
mailing list