mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-05 22:43:15 +00:00
raft_group0: make_raft_config_nonvoter: add raft_timeout parameter
We'll use this parameter in subsequent commits.
This commit is contained in:
@@ -802,7 +802,7 @@ bool raft_group0::is_member(raft::server_id id, bool include_voters_only) {
|
||||
return cfg.contains(id) && (!include_voters_only || cfg.can_vote(id));
|
||||
}
|
||||
|
||||
future<> raft_group0::become_nonvoter(abort_source& as) {
|
||||
future<> raft_group0::become_nonvoter(abort_source& as, std::optional<raft_timeout> timeout) {
|
||||
if (!(co_await raft_upgrade_complete())) {
|
||||
on_internal_error(group0_log, "called become_nonvoter before Raft upgrade finished");
|
||||
}
|
||||
@@ -810,15 +810,17 @@ future<> raft_group0::become_nonvoter(abort_source& as) {
|
||||
auto my_id = load_my_id();
|
||||
group0_log.info("becoming a non-voter (my id = {})...", my_id);
|
||||
|
||||
co_await make_raft_config_nonvoter({my_id}, as);
|
||||
co_await make_raft_config_nonvoter({my_id}, as, timeout);
|
||||
group0_log.info("became a non-voter.", my_id);
|
||||
}
|
||||
|
||||
future<> raft_group0::make_nonvoter(raft::server_id node, abort_source& as) {
|
||||
co_return co_await make_nonvoters({node}, as);
|
||||
future<> raft_group0::make_nonvoter(raft::server_id node, abort_source& as, std::optional<raft_timeout> timeout) {
|
||||
co_return co_await make_nonvoters({node}, as, timeout);
|
||||
}
|
||||
|
||||
future<> raft_group0::make_nonvoters(const std::unordered_set<raft::server_id>& nodes, abort_source& as) {
|
||||
future<> raft_group0::make_nonvoters(const std::unordered_set<raft::server_id>& nodes, abort_source& as,
|
||||
std::optional<raft_timeout> timeout)
|
||||
{
|
||||
if (!(co_await raft_upgrade_complete())) {
|
||||
on_internal_error(group0_log, "called make_nonvoters before Raft upgrade finished");
|
||||
}
|
||||
@@ -829,7 +831,7 @@ future<> raft_group0::make_nonvoters(const std::unordered_set<raft::server_id>&
|
||||
|
||||
group0_log.info("making servers {} non-voters...", nodes);
|
||||
|
||||
co_await make_raft_config_nonvoter(nodes, as);
|
||||
co_await make_raft_config_nonvoter(nodes, as, timeout);
|
||||
|
||||
group0_log.info("servers {} are now non-voters.", nodes);
|
||||
}
|
||||
@@ -917,7 +919,9 @@ future<bool> raft_group0::wait_for_raft() {
|
||||
co_return true;
|
||||
}
|
||||
|
||||
future<> raft_group0::make_raft_config_nonvoter(const std::unordered_set<raft::server_id>& ids, abort_source& as) {
|
||||
future<> raft_group0::make_raft_config_nonvoter(const std::unordered_set<raft::server_id>& ids, abort_source& as,
|
||||
std::optional<raft_timeout> timeout)
|
||||
{
|
||||
static constexpr auto max_retry_period = std::chrono::seconds{1};
|
||||
auto retry_period = std::chrono::milliseconds{10};
|
||||
|
||||
@@ -930,7 +934,7 @@ future<> raft_group0::make_raft_config_nonvoter(const std::unordered_set<raft::s
|
||||
[] (raft::server_id id) { return raft::config_member{{id, {}}, false}; });
|
||||
|
||||
try {
|
||||
co_await _raft_gr.group0().modify_config(std::move(add), {}, &as);
|
||||
co_await _raft_gr.group0_with_timeouts().modify_config(std::move(add), {}, &as, timeout);
|
||||
co_return;
|
||||
} catch (const raft::commit_status_unknown& e) {
|
||||
group0_log.info("make_raft_config_nonvoter({}): modify_config returned \"{}\", retrying", ids, e);
|
||||
|
||||
@@ -215,19 +215,20 @@ public:
|
||||
//
|
||||
// Assumes we've finished the startup procedure (`setup_group0()` finished earlier).
|
||||
// `wait_for_raft` must've also been called earlier and returned `true`.
|
||||
future<> become_nonvoter(abort_source& as);
|
||||
future<> become_nonvoter(abort_source& as, std::optional<raft_timeout> timeout = std::nullopt);
|
||||
|
||||
// Make the given server, other than us, a non-voter in group 0.
|
||||
//
|
||||
// Assumes we've finished the startup procedure (`setup_group0()` finished earlier).
|
||||
// `wait_for_raft` must've also been called earlier and returned `true`.
|
||||
future<> make_nonvoter(raft::server_id, abort_source&);
|
||||
future<> make_nonvoter(raft::server_id, abort_source&, std::optional<raft_timeout> timeout = std::nullopt);
|
||||
|
||||
// Make the given servers, other than us, a non-voter in group 0.
|
||||
//
|
||||
// Assumes we've finished the startup procedure (`setup_group0()` finished earlier).
|
||||
// `wait_for_raft` must've also been called earlier and returned `true`.
|
||||
future<> make_nonvoters(const std::unordered_set<raft::server_id>&, abort_source&);
|
||||
future<> make_nonvoters(const std::unordered_set<raft::server_id>&, abort_source&,
|
||||
std::optional<raft_timeout> timeout = std::nullopt);
|
||||
|
||||
// Remove ourselves from group 0.
|
||||
//
|
||||
@@ -364,7 +365,7 @@ private:
|
||||
|
||||
// Make the given server a non-voter in Raft group 0 configuration.
|
||||
// Retries on raft::commit_status_unknown.
|
||||
future<> make_raft_config_nonvoter(const std::unordered_set<raft::server_id>&, abort_source& as);
|
||||
future<> make_raft_config_nonvoter(const std::unordered_set<raft::server_id>&, abort_source& as, std::optional<raft_timeout> timeout = std::nullopt);
|
||||
|
||||
// Returns true if raft is enabled
|
||||
future<bool> use_raft();
|
||||
|
||||
Reference in New Issue
Block a user