Skip to content

Commit

Permalink
Last gasp check
Browse files Browse the repository at this point in the history
Don't prompt changes on a ring_update is the updated ring is a last gasp of a local node closing down.
  • Loading branch information
martinsumner committed Oct 28, 2019
1 parent 8fcc415 commit db76bba
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/riak_repl_ring_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ handle_event({ring_update, Ring}, State=#state{ring=Ring}) ->
{ok, State};
handle_event({ring_update, NewRing}, State=#state{ring=OldRing}) ->
%% Ring has changed.
FinalRing = init_repl_config(OldRing, NewRing),
update_leader(FinalRing),
_ = rt_update_events(FinalRing),
_ = pg_update_events(FinalRing),
riak_repl_listener_sup:ensure_listeners(FinalRing),
case riak_repl_leader:is_leader() of
case riak_core_ring:check_lastgasp(NewRing) of
true ->
riak_repl_leader:ensure_sites();
_ ->
ok
end,
%% Force the cluster manager to connect to the clusters when it
%% learns about an event *after* an election has occurred.
case riak_repl2_leader:is_leader() of
true ->
riak_core_cluster_mgr:connect_to_clusters();
_ ->
ok
end,
{ok, State#state{ring=FinalRing}};
{ok, State};
false ->
FinalRing = init_repl_config(OldRing, NewRing),
update_leader(FinalRing),
_ = rt_update_events(FinalRing),
_ = pg_update_events(FinalRing),
riak_repl_listener_sup:ensure_listeners(FinalRing),
case riak_repl_leader:is_leader() of
true ->
riak_repl_leader:ensure_sites();
_ ->
ok
end,
%% Force the cluster manager to connect to the clusters when it
%% learns about an event *after* an election has occurred.
case riak_repl2_leader:is_leader() of
true ->
riak_core_cluster_mgr:connect_to_clusters();
_ ->
ok
end,
{ok, State#state{ring=FinalRing}}
end;
handle_event(_Event, State) ->
{ok, State}.

Expand Down

0 comments on commit db76bba

Please sign in to comment.