Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor leave - balance and tail violations #972

Merged
merged 15 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions priv/riak_core.schema
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,22 @@
hidden
]}.

%% @doc On cluster leave - force full rebalance partitions
%% By default on a cluster leave there will first be an attempt to handoff
%% vnodes to safe (in terms of target_n_val) locations. In small clusters,
%% there may be insufficient safe locations, and a temporary state can be
%% created where a single node has a large number of vnodes.
%% To mitigate this, a full rebalance (a re-assignment that does not optimise
%% based on the starting position), can be forced by setting this option on
%% all nodes.
%% Please carefully consider any cluster plan created with this option before
%% committing
{mapping, "full_rebalance_onleave", "riak_core.full_rebalance_onleave", [
{datatype, flag},
{default, off}
]}.


%% Async Job Management
%%
%% This is a translation for mappings that appear in other schema files.
Expand Down
7 changes: 6 additions & 1 deletion src/riak_core_claim.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
choose_claim_v2/1, choose_claim_v2/2, choose_claim_v2/3,
choose_claim_v3/1, choose_claim_v3/2, choose_claim_v3/3,
claim_rebalance_n/2, claim_diversify/3, claim_diagonal/3,
wants/1, wants_owns_diff/2, meets_target_n/2, diagonal_stripe/2]).
wants/1, wants_owns_diff/2, meets_target_n/2, diagonal_stripe/2,
sequential_claim/2, get_counts/2]).

-ifdef(TEST).
-compile(export_all).
Expand Down Expand Up @@ -620,6 +621,10 @@ claim_diagonal(Wants, Owners, Params) ->
end,
{lists:flatten([lists:duplicate(Reps, Claiming), Last]), [diagonalized]}.

sequential_claim(Ring, Node) ->
TN = app_helper:get_env(riak_core, target_n_val, ?DEF_TARGET_N),
sequential_claim(Ring, Node, TN).

%% @private fall back to diagonal striping vnodes across nodes in a
%% sequential round robin (eg n1 | n2 | n3 | n4 | n5 | n1 | n2 | n3
%% etc) However, different to `claim_rebalance_n', this function
Expand Down
10 changes: 10 additions & 0 deletions src/riak_core_console.erl
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,16 @@ print_plan(Changes, Ring, NextRings) ->
"cluster transitions~n~n", [Transitions])
end,

Leaves = length(lists:filter(fun({_N, A}) -> A == leave end, Changes)) > 0,

case Leaves and app_helper:get_env(riak_core, full_rebalance_onleave) of
true ->
io:format("WARNING: Full rebalance forced by non-default "
"option riak_core.full_rebalance_onleave = true~n~n");
_ ->
ok
end,

_ = lists:foldl(fun({Ring1, Ring2}, I) ->
io:format("~79..#s~n", [""]),
io:format("~24.. s After cluster transition ~b/~b~n",
Expand Down
Loading