Skip to content
This repository
Browse code

Added vnode callbacks for handling shutdown commands.

RiakKV FSMs blow up when they receive non-{r, blah, Idx, ReqId} and
{fail, Idx, ReqId} messages.  Added an optional callback to the
vnode module to handle messages during shutdown.
  • Loading branch information...
commit 423fe65d0877f270f075a78f119d282cbdb25f01 1 parent 347a9eb
Jon Meredith authored September 21, 2011

Showing 1 changed file with 31 additions and 7 deletions. Show diff stats Hide diff stats

  1. 38  src/riak_core_vnode.erl
38  src/riak_core_vnode.erl
@@ -323,15 +323,39 @@ active(_Event, _From, State) ->
323 323
     Reply = ok,
324 324
     {reply, Reply, active, State, State#state.inactivity_timeout}.
325 325
 
326  
-shutdown(Event, State=#state{index=Idx, mod=Mod}) 
  326
+shutdown(Event, State) 
327 327
   when Event == timeout; Event == stop ->
328 328
     {stop, normal, State};
329  
-shutdown(?VNODE_REQ{sender = Sender}, State) ->
330  
-    riak_core_vnode:reply(Sender, {error, shutdown}),
331  
-    {next_state, shutdown, State, ?SHUTDOWN_TIMEOUT};
332  
-shutdown(?COVERAGE_REQ{sender = Sender}, State) ->
333  
-    riak_core_vnode:reply(Sender, {error, shutdown}),
334  
-    {next_state, shutdown, State, ?SHUTDOWN_TIMEOUT};
  329
+shutdown(?VNODE_REQ{sender = Sender, request = Request},
  330
+         State=#state{mod = Mod, modstate = ModState}) ->
  331
+    Action = try
  332
+                Mod:handle_shutdown_command(Request, Sender, ModState)
  333
+            catch
  334
+                _:_ ->
  335
+                    {reply, {error, shutdown}, ModState}
  336
+            end,
  337
+    case Action of
  338
+        {reply, Reply, ModState1} ->
  339
+            riak_core_vnode:reply(Sender, Reply),
  340
+            {next_state, shutdown, State#state{modstate = ModState1}, ?SHUTDOWN_TIMEOUT};
  341
+        {noreply, ModState1} ->
  342
+            {next_state, shutdown, State#state{modstate = ModState1}, ?SHUTDOWN_TIMEOUT}
  343
+    end;
  344
+shutdown(?COVERAGE_REQ{sender = Sender, request = Request},
  345
+         State=#state{mod = Mod, modstate = ModState}) ->
  346
+    Action = try
  347
+                Mod:handle_shutdown_coverage(Request, Sender, ModState)
  348
+            catch
  349
+                _:_ ->
  350
+                    {error, shutdown}
  351
+            end,
  352
+    case Action of
  353
+        {reply, Reply, ModState1} ->
  354
+            riak_core_vnode:reply(Sender, Reply),
  355
+            {next_state, shutdown, State#state{modstate = ModState1}, ?SHUTDOWN_TIMEOUT};
  356
+        {noreply, ModState1} ->
  357
+            {next_state, shutdown, State#state{modstate = ModState1}, ?SHUTDOWN_TIMEOUT}
  358
+    end;
335 359
 shutdown(_, State) ->
336 360
     {next_state, shutdown, State, ?SHUTDOWN_TIMEOUT}.
337 361
 

0 notes on commit 423fe65

Please sign in to comment.
Something went wrong with that request. Please try again.