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

Develop 2.2.8 workerpool shutdown bugfix #4

Open
wants to merge 5 commits into
base: develop-3.1
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion src/riak_core_vnode_worker_pool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,22 @@ handle_sync_event({shutdown, Time}, From, _StateName, #state{queue=Q,
handle_sync_event(_Event, _From, StateName, State) ->
{reply, {error, unknown_message}, StateName, State}.

handle_info({'DOWN', _Ref, _, Pid, Info}, shutdown, #state{monitors=Monitors} = State) ->
%% remove the listing for the dead worker
case lists:keytake(Pid, 1, Monitors) of
{value, {Pid, _, From, Work}, []} ->
riak_core_vnode:reply(From, {error, {worker_crash, Info, Work}}),
gen_server:reply(State#state.shutdown, ok),
{stop, shutdown, State#state{monitors = []}};
{value, {Pid, _, From, Work}, Monitors1} ->
riak_core_vnode:reply(From, {error, {worker_crash, Info, Work}}),
%% trigger to do more work will be 'worker_start' message
%% when poolboy replaces this worker (if not a 'checkin'
%% or 'handle_work')
{next_state, shutdown, State#state{monitors = Monitors1}};
false ->
{next_state, shutdown, State}
end;
handle_info({'DOWN', _Ref, _, Pid, Info}, StateName, #state{monitors=Monitors} = State) ->
%% remove the listing for the dead worker
case lists:keyfind(Pid, 1, Monitors) of
Expand All @@ -195,7 +211,7 @@ handle_info({'DOWN', _Ref, _, Pid, Info}, StateName, #state{monitors=Monitors} =
end;
handle_info(shutdown, shutdown, #state{monitors=Monitors} = State) ->
%% we've waited too long to shutdown, time to force the issue.
_ = [riak_core_vnode:reply(From, {error, vnode_shutdown}) ||
_ = [riak_core_vnode:reply(From, {error, vnode_shutdown}) ||
{_, _, From, _} <- Monitors],
{stop, shutdown, State};
handle_info(_Info, StateName, State) ->
Expand Down