Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed handling of janitor aborting

Change-Id: I393dfa79c5a39b85683dfde31233804b85418869
Reviewed-on: http://review.northscale.com/3186
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Sean Lynch <seanl@literati.org>
  • Loading branch information...
commit ca2e5854e660c04d382736f4ba43c85b61924ebf 1 parent e5e1e3f
@alk alk authored seanlynch committed
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/ns_orchestrator.erl
View
14 src/ns_orchestrator.erl
@@ -155,6 +155,8 @@ handle_info(janitor, idle, #idle_state{remaining_buckets=[]} = State) ->
handle_info(janitor, idle, #idle_state{remaining_buckets=Buckets}) ->
Bucket = hd(Buckets),
Pid = proc_lib:spawn_link(ns_janitor, cleanup, [Bucket]),
+ %% NOTE: Bucket will be popped from Buckets when janitor run will
+ %% complete successfully
{next_state, janitor_running, #janitor_state{remaining_buckets=Buckets,
pid = Pid}};
handle_info(janitor, StateName, StateData) ->
@@ -258,11 +260,15 @@ idle(stop_rebalance, _From, State) ->
janitor_running(rebalance_progress, _From, State) ->
{reply, not_running, janitor_running, State};
janitor_running(Msg, From, #janitor_state{pid=Pid} = State) ->
+ %% when handling some call while janitor is running we kill janitor
exit(Pid, shutdown),
- NextState = receive
- {'EXIT', Pid, _} = DeathMsg ->
- handle_info(DeathMsg, janitor_running, State)
- end,
+ %% than await that it's dead and handle it's death message
+ {next_state, idle, NextState}
+ = receive
+ {'EXIT', Pid, _} = DeathMsg ->
+ handle_info(DeathMsg, janitor_running, State)
+ end,
+ %% and than handle original call in idle state
idle(Msg, From, NextState).
%% Asynchronous rebalancing events
Please sign in to comment.
Something went wrong with that request. Please try again.