Permalink
Browse files

Interim fix for 719. Handle errors more gracefully by taking down the…

… process cleanly; we need to eventually revisit the process linking model. It is acceptable for this transfer to terminate before it's complete -- the sender will retry.
  • Loading branch information...
1 parent ddf2ef5 commit c52977672d12b557779c95e897c9543a0f407175 @dizzyd dizzyd committed Sep 24, 2010
Showing with 15 additions and 5 deletions.
  1. +15 −5 src/riak_core_handoff_receiver.erl
@@ -43,15 +43,25 @@ init([Socket]) ->
inet:setopts(Socket, [{active, once}, {packet, 4}, {header, 1}]),
{ok, #state{sock=Socket, count=0}}.
-handle_info({tcp_closed,Socket},State=#state{sock=Socket,partition=Partition,count=Count}) ->
+handle_info({tcp_closed,_Socket},State=#state{partition=Partition,count=Count}) ->
error_logger:info_msg("Handoff receiver for partition ~p exiting after processing ~p"
" objects~n", [Partition, Count]),
{stop, normal, State};
-handle_info({tcp, _Sock, Data}, State=#state{sock=Socket}) ->
+handle_info({tcp_error, _Socket, _Reason}, State=#state{partition=Partition,count=Count}) ->
+ error_logger:info_msg("Handoff receiver for partition ~p exiting after processing ~p"
+ " objects~n", [Partition, Count]),
+ {stop, normal, State};
+handle_info({tcp, _Socket, Data}, State) ->
[MsgType|MsgData] = Data,
- NewState = process_message(MsgType,MsgData,State),
- inet:setopts(Socket, [{active, once}]),
- {noreply, NewState}.
+ case catch(process_message(MsgType, MsgData, State)) of
+ {'EXIT', Reason} ->
+ error_logger:error_msg("Handoff receiver for partition ~p exiting abnormally after "
+ "processing ~p objects: ~p\n", [State#state.count, Reason]),
+ {stop, normal, State};
+ NewState when is_record(NewState, state) ->
+ {noreply, NewState}
+ end.
+
process_message(?PT_MSG_INIT, MsgData, State=#state{vnode_mod=VNodeMod}) ->
<<Partition:160/integer>> = MsgData,

0 comments on commit c529776

Please sign in to comment.