Skip to content

Commit

Permalink
Reply to clients when a partition is deleted
Browse files Browse the repository at this point in the history
Change-Id: I0c74b33d7453bf84838f16e32278720123360478
Reviewed-on: http://review.couchbase.org/13021
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: buildbot <qe@couchbase.com>
  • Loading branch information
fdmanana committed Feb 6, 2012
1 parent 7c76cf6 commit af2c510
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/couch_set_view/src/couch_set_view_group.erl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -366,13 +366,15 @@ handle_call(is_view_defined, _From, #state{group = Group} = State) ->
{reply, is_integer(?set_num_partitions(Group)), State, ?TIMEOUT}; {reply, is_integer(?set_num_partitions(Group)), State, ?TIMEOUT};


handle_call({partition_deleted, master}, _From, State) -> handle_call({partition_deleted, master}, _From, State) ->
{stop, shutdown, shutdown, State}; Reason = {db_deleted, ?master_dbname((?set_name(State)))},
{stop, shutdown, shutdown, reply_all(State, {error, Reason})};
handle_call({partition_deleted, PartId}, _From, #state{group = Group} = State) -> handle_call({partition_deleted, PartId}, _From, #state{group = Group} = State) ->
Mask = 1 bsl PartId, Mask = 1 bsl PartId,
case ((?set_abitmask(Group) band Mask) =/= 0) orelse case ((?set_abitmask(Group) band Mask) =/= 0) orelse
((?set_pbitmask(Group) band Mask) =/= 0) of ((?set_pbitmask(Group) band Mask) =/= 0) of
true -> true ->
{stop, shutdown, shutdown, State}; Reason = {db_deleted, ?dbname((?set_name(State)), PartId)},
{stop, shutdown, shutdown, reply_all(State, {error, Reason})};
false -> false ->
{reply, ignore, State, ?TIMEOUT} {reply, ignore, State, ?TIMEOUT}
end; end;
Expand Down Expand Up @@ -871,9 +873,13 @@ reply_with_group(Group0, Stats, WaitList) ->
gen_server:reply(From, {ok, Group, ActiveReplicasBitmask}) gen_server:reply(From, {ok, Group, ActiveReplicasBitmask})
end, WaitList). end, WaitList).


reply_all(#state{waiting_list=WaitList}=State, Reply) ->
[catch gen_server:reply(From, Reply) || From <- WaitList], reply_all(#state{waiting_list = []} = State, _Reply) ->
State#state{waiting_list=[]}. State;
reply_all(#state{waiting_list = WaitList} = State, Reply) ->
lists:foreach(fun(From) -> catch gen_server:reply(From, Reply) end, WaitList),
State#state{waiting_list = []}.



prepare_group({RootDir, SetName, #set_view_group{sig = Sig, type = Type} = Group}, ForceReset)-> prepare_group({RootDir, SetName, #set_view_group{sig = Sig, type = Type} = Group}, ForceReset)->
case open_index_file(RootDir, SetName, Type, Sig) of case open_index_file(RootDir, SetName, Type, Sig) of
Expand Down

0 comments on commit af2c510

Please sign in to comment.