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 03/12] raft: stop using replication_disconnect_timeout()
Date: Tue, 17 Nov 2020 11:15:05 +0300 [thread overview]
Message-ID: <5c4186bd-f6b7-d765-9940-82dfca945082@tarantool.org> (raw)
In-Reply-To: <37cac52adcfbc1ff4caf0399fec9d2f0213c9c0b.1605570907.git.v.shpilevoy@tarantool.org>
LGTM.
17.11.2020 03:02, Vladislav Shpilevoy пишет:
> Raft is being moved to a separate library in src/lib. It means,
> it can't depend on anything from box/, including global
> replication parameters such as replication_timeout, and functions
> like replication_disconnect_timeout().
>
> The patch makes raft stop using replication_disconnect_timeout().
> Instead, it stores death timeout in struct raft. It is configured
> by box simultaneously with replication_timeout.
>
> Part of #5303
> ---
> src/box/box.cc | 2 +-
> src/box/raftlib.c | 13 ++++++-------
> src/box/raftlib.h | 10 +++++++---
> 3 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 8dd92a5f5..25673ed42 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -890,7 +890,7 @@ void
> box_set_replication_timeout(void)
> {
> replication_timeout = box_check_replication_timeout();
> - raft_cfg_death_timeout(box_raft());
> + raft_cfg_death_timeout(box_raft(), replication_disconnect_timeout());
> }
>
> void
> diff --git a/src/box/raftlib.c b/src/box/raftlib.c
> index 3867c63e0..c156d6f46 100644
> --- a/src/box/raftlib.c
> +++ b/src/box/raftlib.c
> @@ -804,8 +804,7 @@ raft_sm_wait_leader_dead(struct raft *raft)
> assert(raft->is_candidate);
> assert(raft->state == RAFT_STATE_FOLLOWER);
> assert(raft->leader != 0);
> - double death_timeout = replication_disconnect_timeout();
> - ev_timer_set(&raft->timer, death_timeout, death_timeout);
> + ev_timer_set(&raft->timer, raft->death_timeout, raft->death_timeout);
> ev_timer_start(loop(), &raft->timer);
> }
>
> @@ -817,8 +816,7 @@ raft_sm_wait_leader_found(struct raft *raft)
> assert(raft->is_candidate);
> assert(raft->state == RAFT_STATE_FOLLOWER);
> assert(raft->leader == 0);
> - double death_timeout = replication_disconnect_timeout();
> - ev_timer_set(&raft->timer, death_timeout, death_timeout);
> + ev_timer_set(&raft->timer, raft->death_timeout, raft->death_timeout);
> ev_timer_start(loop(), &raft->timer);
> }
>
> @@ -1012,14 +1010,14 @@ raft_cfg_election_quorum(struct raft *raft)
> }
>
> void
> -raft_cfg_death_timeout(struct raft *raft)
> +raft_cfg_death_timeout(struct raft *raft, double death_timeout)
> {
> + raft->death_timeout = death_timeout;
> if (raft->state == RAFT_STATE_FOLLOWER && raft->is_candidate &&
> raft->leader != 0) {
> assert(ev_is_active(&raft->timer));
> - double death_timeout = replication_disconnect_timeout();
> double timeout = ev_timer_remaining(loop(), &raft->timer) -
> - raft->timer.at + death_timeout;
> + raft->timer.at + raft->death_timeout;
> ev_timer_stop(loop(), &raft->timer);
> ev_timer_set(&raft->timer, timeout, timeout);
> ev_timer_start(loop(), &raft->timer);
> @@ -1080,6 +1078,7 @@ raft_create(struct raft *raft)
> .volatile_term = 1,
> .term = 1,
> .election_timeout = 5,
> + .death_timeout = 5,
> };
> ev_timer_init(&raft->timer, raft_sm_schedule_new_election_cb, 0, 0);
> raft->timer.data = raft;
> diff --git a/src/box/raftlib.h b/src/box/raftlib.h
> index 805f69d64..b33a20326 100644
> --- a/src/box/raftlib.h
> +++ b/src/box/raftlib.h
> @@ -156,6 +156,11 @@ struct raft {
> struct fiber *worker;
> /** Configured election timeout in seconds. */
> double election_timeout;
> + /**
> + * Leader death timeout, after which it is considered dead and new
> + * elections can be started.
> + */
> + double death_timeout;
> /**
> * Trigger invoked each time any of the Raft node visible attributes are
> * changed.
> @@ -229,11 +234,10 @@ raft_cfg_election_quorum(struct raft *raft);
>
> /**
> * Configure Raft leader death timeout. I.e. number of seconds without
> - * heartbeats from the leader to consider it dead. There is no a separate
> - * option. Raft uses replication timeout for that.
> + * heartbeats from the leader to consider it dead.
> */
> void
> -raft_cfg_death_timeout(struct raft *raft);
> +raft_cfg_death_timeout(struct raft *raft, double death_timeout);
>
> /**
> * Bump the term. When it is persisted, the node checks if there is a leader,
--
Serge Petrenko
next prev parent reply other threads:[~2020-11-17 8:15 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 [this message]
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
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=5c4186bd-f6b7-d765-9940-82dfca945082@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 03/12] raft: stop using replication_disconnect_timeout()' \
/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