From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org Subject: [Tarantool-patches] [PATCH v2 03/16] raft: stop using replication_disconnect_timeout() Date: Fri, 20 Nov 2020 00:46:06 +0100 [thread overview] Message-ID: <5a1915c39df4118bdeeed55bf9885556472ddd6c.1605829282.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1605829282.git.v.shpilevoy@tarantool.org> 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, -- 2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2020-11-19 23:46 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-19 23:45 [Tarantool-patches] [PATCH v2 00/16] Raft module, part 2 - relocation to src/lib/raft Vladislav Shpilevoy 2020-11-19 23:45 ` [Tarantool-patches] [PATCH v2 01/16] raft: move sources to raftlib.h/.c Vladislav Shpilevoy 2020-11-19 23:45 ` [Tarantool-patches] [PATCH v2 10/16] raft: make worker non-cancellable during WAL write Vladislav Shpilevoy 2020-11-20 8:33 ` Serge Petrenko 2020-11-19 23:45 ` [Tarantool-patches] [PATCH v2 11/16] raft: move worker fiber from Raft library to box Vladislav Shpilevoy 2020-11-20 9:06 ` Serge Petrenko 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 12/16] raft: move synchro queue clear to the worker fiber Vladislav Shpilevoy 2020-11-20 9:07 ` Serge Petrenko 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 13/16] raft: invoke update triggers within state machine Vladislav Shpilevoy 2020-11-20 9:10 ` Serge Petrenko 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 14/16] raft: move RO summary update to box-Raft Vladislav Shpilevoy 2020-11-20 9:13 ` Serge Petrenko 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 15/16] raft: introduce RaftError Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 16/16] raft: move algorithm code to src/lib/raft Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 02/16] raft: move box_raft_* to src/box/raft.h and .c Vladislav Shpilevoy 2020-11-19 23:46 ` Vladislav Shpilevoy [this message] 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 04/16] raft: stop using replication_synchro_quorum Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 05/16] raft: stop using instance_id Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 06/16] raft: make raft_request.vclock constant Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 07/16] raft: stop using replicaset.vclock Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 08/16] raft: introduce vtab for disk and network Vladislav Shpilevoy 2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 09/16] raft: introduce raft_msg, drop xrow dependency Vladislav Shpilevoy 2020-11-20 9:14 ` [Tarantool-patches] [PATCH v2 00/16] Raft module, part 2 - relocation to src/lib/raft Serge Petrenko 2020-11-20 19:42 ` Vladislav Shpilevoy 2020-11-23 5:30 ` Alexander V. Tikhonov 2020-11-23 23:26 ` Vladislav Shpilevoy
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=5a1915c39df4118bdeeed55bf9885556472ddd6c.1605829282.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 03/16] 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