Permalink
Browse files

Merge branch 'slf-otp-app-restart-fixes'

  • Loading branch information...
2 parents 076316d + 5a0ee9d commit 7bf99d6adbc84872e14c2686232e7faf85e66869 @slfritchie slfritchie committed Feb 28, 2011
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/riak_core_ring_handler.erl
View
26 src/riak_core_ring_handler.erl
@@ -73,7 +73,20 @@ ensure_vnodes_started([H|T], Ring, Acc) ->
ensure_vnodes_started(Mod, Ring) ->
Startable = startable_vnodes(Mod, Ring),
- [Mod:start_vnode(I) || I <- Startable],
+ %% NOTE: This following is a hack. There's a basic
+ %% dependency/race between riak_core (want to start vnodes
+ %% right away to trigger possible handoffs) and riak_kv
+ %% (needed to support those vnodes). The hack does not fix
+ %% that dependency: internal techdebt todo list #A7 does.
+ spawn_link(fun() ->
+ try register(riak_core_ring_handler_ensure, self())
+ catch error:badarg ->
+ exit(normal)
+ end,
+ wait_for_kv_app(100, 100),
+ [Mod:start_vnode(I) || I <- Startable],
+ exit(normal)
+ end),
Startable.
startable_vnodes(Mod, Ring) ->
@@ -95,3 +108,14 @@ startable_vnodes(Mod, Ring) ->
[RO | riak_core_ring:my_indices(Ring)]
end
end.
+
+wait_for_kv_app(0, _) ->
+ bummer;
+wait_for_kv_app(Count, Sleep) ->
+ case lists:keymember(riak_kv, 1, application:which_applications()) of
+ true ->
+ ok;
+ false ->
+ timer:sleep(Sleep),
+ wait_for_kv_app(Count - 1, Sleep)
+ end.

0 comments on commit 7bf99d6

Please sign in to comment.