Anonymous avatar Anonymous committed c68d936

remove mnesia, locking, and spawn

Comments (0)

Files changed (3)

   {registered,   []},
   {mod,          {riak_app, []}},
   {env,          []},
-  {applications, [kernel, stdlib, sasl, crypto, mnesia]}]}.
+  {applications, [kernel, stdlib, sasl, crypto]}]}.
     erlang:system_flag(fullsweep_after, 20),
     ensure_started(sasl),
     ensure_started(crypto),
-    ensure_started(mnesia),
     ensure_started(webmachine),
     application:start(riak, permanent).
 

src/riak_vnode.erl

             State=#state{mapcache=Cache,mod=Mod,modstate=ModState}) ->
     riak_eventer:notify(riak_vnode, map, QTerm),
     VNode = self(),
-    spawn(fun() -> 
-              do_map(ClientPid,QTerm,Storekey,KeyData,Cache,Mod,ModState,VNode)
-          end),
+    do_map(ClientPid,QTerm,Storekey,KeyData,Cache,Mod,ModState,VNode),
     {noreply, State};
 handle_cast({put, FSM_pid, Storekey, RObj, ReqID},
             State=#state{mapcache=Cache,idx=Idx}) ->
     riak_eventer:notify(riak_vnode, put, ReqID),
     gen_fsm:send_event(FSM_pid, {w, Idx, ReqID}),
-    spawn(fun() -> do_put(FSM_pid, Storekey, RObj, ReqID, State) end),
+    do_put(FSM_pid, Storekey, RObj, ReqID, State),
     {noreply, State#state{mapcache=dict:erase(Storekey,Cache)}};
 handle_cast({get, FSM_pid, Storekey, ReqID}, State) ->
     riak_eventer:notify(riak_vnode, get, ReqID),
-    spawn(fun() -> do_get(FSM_pid, Storekey, ReqID, State) end),
+    do_get(FSM_pid, Storekey, ReqID, State),
     {noreply, State};
 handle_cast({delete, Client, Storekey, ReqID}, State) ->
     riak_eventer:notify(riak_vnode, delete, ReqID),
-    spawn(fun() -> do_delete(Client, Storekey, ReqID, State) end),
+    do_delete(Client, Storekey, ReqID, State),
     {noreply, State}.
 
 %% @private
 
 do_delete(Client, Storekey, ReqID,
           _State=#state{idx=Idx,mod=Mod,modstate=ModState}) ->
-    Trans = fun() ->
-            mnesia:lock({global, Storekey, [node()]}, write),
-            case Mod:delete(ModState, Storekey) of
-                ok ->
-                    riak_eventer:notify(riak_vnode,delete_reply,ReqID),
-                    gen_server2:reply(Client, {del, Idx, ReqID});
-                {error, Reason} ->
-                    riak_eventer:notify(riak_vnode,delete_fail,{ReqID,Reason}),
-                    gen_server2:reply(Client, {fail, Idx, ReqID})
-            end
-    end,
-    {atomic, _} = mnesia:transaction(Trans).
+    case Mod:delete(ModState, Storekey) of
+        ok ->
+            riak_eventer:notify(riak_vnode,delete_reply,ReqID),
+            gen_server2:reply(Client, {del, Idx, ReqID});
+        {error, Reason} ->
+            riak_eventer:notify(riak_vnode,delete_fail,{ReqID,Reason}),
+            gen_server2:reply(Client, {fail, Idx, ReqID})
+    end.
 
 simple_binary_put(Storekey, Val, Mod, ModState) ->
     Mod:put(ModState, Storekey, Val).
 
 do_put(FSM_pid, Storekey, RObj, ReqID,
        _State=#state{idx=Idx,mod=Mod,modstate=ModState}) ->
-    Trans = fun() ->
-            mnesia:lock({global, Storekey, [node()]}, write),
-            case syntactic_put_merge(Mod, ModState, Storekey, RObj) of
-                oldobj -> 
+    case syntactic_put_merge(Mod, ModState, Storekey, RObj) of
+        oldobj -> 
+            riak_eventer:notify(riak_vnode,put_reply,ReqID),
+            gen_fsm:send_event(FSM_pid, {dw, Idx, ReqID});
+        {newobj, ObjToStore} ->
+            Val = term_to_binary(ObjToStore, [compressed]),
+            case simple_binary_put(Storekey, Val, Mod, ModState) of
+                ok ->
                     riak_eventer:notify(riak_vnode,put_reply,ReqID),
                     gen_fsm:send_event(FSM_pid, {dw, Idx, ReqID});
-                {newobj, ObjToStore} ->
-                    Val = term_to_binary(ObjToStore, [compressed]),
-                    case simple_binary_put(Storekey, Val, Mod, ModState) of
-                        ok ->
-                            riak_eventer:notify(riak_vnode,put_reply,ReqID),
-                            gen_fsm:send_event(FSM_pid, {dw, Idx, ReqID});
                 {error, Reason} ->
-                            riak_eventer:notify(riak_vnode,put_fail,{ReqID,Reason}),
-                            gen_fsm:send_event(FSM_pid, {fail, Idx, ReqID})
-                    end
+                    riak_eventer:notify(riak_vnode,put_fail,{ReqID,Reason}),
+                    gen_fsm:send_event(FSM_pid, {fail, Idx, ReqID})
             end
-            end,
-    {atomic, _} = mnesia:transaction(Trans).
+    end.
 
 do_map(ClientPid,{map,FunTerm,Arg,_Acc},
        Storekey,KeyData,Cache,Mod,ModState,VNode) ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.