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

Cleanup rt_dirty behavior #389

Closed
wants to merge 2 commits into from
Closed
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
25 changes: 23 additions & 2 deletions src/riak_repl2_fscoordinator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ handle_cast(start_fullsync, State) ->
lager:info("Starting fullsync (source) with max_fssource_node=~p and max_fssource_cluster=~p",
[MaxSource, MaxCluster]),
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
check_nodes_for_rt_dirty(Ring),
N = largest_n(Ring),
Partitions = sort_partitions(Ring),
State2 = State#state{
Expand Down Expand Up @@ -742,8 +743,17 @@ notify_rt_dirty_nodes(State = #state{dirty_nodes = DirtyNodes,
NodesToNotify = lists:subtract(AllNodesList,
ordsets:to_list(DirtyNodesDuringFS)),
lager:debug("Notifying nodes ~p", [ NodesToNotify]),
rpc:multicall(NodesToNotify, riak_repl_stats, clear_rt_dirty, []),
State#state{dirty_nodes=ordsets:new()};
{_, BadNodes} = rpc:multicall(NodesToNotify,
riak_repl_stats,
clear_rt_dirty, []),
case BadNodes of
[] ->
%% all nodes nodified, clear rt_dirty state
State#state{dirty_nodes=ordsets:new()};
Nodes ->
lager:warning("Failed to clear rt_dirty on ~p", [Nodes]),
State
end;
false ->
lager:debug("No dirty nodes before fullsync started"),
State
Expand All @@ -762,3 +772,14 @@ notify_rt_dirty_nodes(State = #state{dirty_nodes = DirtyNodes,

nodeset_to_string_list(Set) ->
string:join([erlang:atom_to_list(V) || V <- ordsets:to_list(Set)],",").


%% check all nodes in the cluster for existing rt_dirty files
%% and reset their rt_dirty flag if it exists
check_nodes_for_rt_dirty(Ring) ->
Owners = riak_core_ring:all_owners(Ring),
[ case rpc:call(Node, riak_repl_stats, is_rt_dirty,[]) of
false -> ok;
_ -> riak_repl2_fscoordinator:node_dirty(Node)
end || Node <- Owners ].

6 changes: 4 additions & 2 deletions src/riak_repl_stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ rt_dirty() ->
riak_repl2_fscoordinator:node_dirty(node())
catch
_:_ ->
lager:debug("Failed to notify coordinator of rt_dirty status")
end
%% This could be triggered on startup if the
%% fscoordinator isn't running
lager:warning("Failed to notify coordinator of rt_dirty status.")
end
end),
ok;
false -> ok
Expand Down