riak_core questions

Dmitry Demeshchuk demeshchuk at gmail.com
Thu Jul 28 08:45:47 EDT 2011


Greetings. I'm building an application on top of riak_core and I got
several questions about how all this stuff works.

1. When a node goes down, I need to force its exclusion from the
cluster, so the vnodes will be redistributed between the working
nodes.

As far as I understad, the easiest way to do it is something like that:


==================================================
...
riak_core_node_watcher_events:add_handler(failover_module, []),
...
==================================================
-module(failover_module).
-behaviour(gen_event).
....
handle_event({service_update, [Service]}, State) ->
    NewNodes = riak_core_node_watcher:nodes(Service),
    OldNodes = riak_core_ring:all_members(riak_core_ring_manager:get_my_ring()),
    [Node2Remove] = OldNodes -- NewNodes,
    riak_core:remove_from_cluster(Node2Remove),
    {ok, State}
======================================================

Isn't there an easier way than that? Also, it's not obvious to me if I
should execute this code on each node, or when it's executed all the
nodes in the ring are automatically updated.

2. When a node goes up, there are 2 possible scenarios: if the node
did exist in the cluster before, we have to add it manually (which is
okay); and if the node did exist in the cluster before going down, it
gets the master node from the ring file and makes rpc:call which adds
this node back to the cluster.

3. Each vnode has an attached process that does some stuff. When the
cluster is re-arranged (and vnodes are re-distributed among Erlang
nodes), I still need those attached processes to finish all the stuff
they are doing, and only then start moving the corresponding vnode to
the new node. Is it enough just to wait for the corresponding message
{you_can_move_vnode_now} at riak_more_vnode_module:terminate/2, or it
needs to be done in some other way?

4. Finally, I'm a bit concerned about what happens to the cluster if
the master node goes down. Probably, we cannot remove master node from
the cluster. Or riak_core automatically elects the new master node in
such a case (unlikely, I haven't found any gen_leader-like stuff).
What's the best way to handle such situations?

Thank you.


-- 
Best regards,
Dmitry Demeshchuk




More information about the riak-users mailing list