Skip to content
Browse files

Shut down memcached buckets when failing over a node

Change-Id: I646bf4d21cd62be791f54937582395082ffeec91
Reviewed-on: http://review.northscale.com/3208
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
1 parent 84b8ec4 commit 44e0bc22ef84a9c53a058a4c09f233e305a835ee @seanlynch seanlynch committed with alk Oct 11, 2010
Showing with 22 additions and 15 deletions.
  1. +22 −15 src/ns_rebalancer.erl
View
37 src/ns_rebalancer.erl
@@ -37,24 +37,31 @@
%% effect immediately.
failover(Node) ->
lists:foreach(fun (Bucket) -> failover(Bucket, Node) end,
- ns_bucket:get_bucket_names(membase)).
+ ns_bucket:get_bucket_names()).
-spec failover(string(), atom()) -> ok.
failover(Bucket, Node) ->
- {_, _, Map, Servers} = ns_bucket:config(Bucket),
- %% Promote replicas of vbuckets on this node
- Map1 = promote_replicas(Map, [Node]),
- case [I || {I, [undefined|_]} <- misc:enumerate(Map1, 0)] of
- [] -> ok; % Phew!
- MissingVBuckets ->
- ?log_error("Lost data in ~p for ~w", [Bucket, MissingVBuckets]),
- ns_log:log(?MODULE, 1,
- "Data has been lost for ~B% of vbuckets in bucket ~p.",
- [length(MissingVBuckets) * 100 div length(Map), Bucket])
- end,
- ns_bucket:set_map(Bucket, Map1),
- ns_bucket:set_servers(Bucket, lists:delete(Node, Servers)),
- ns_janitor:cleanup(Bucket).
+ {ok, BucketConfig} = ns_bucket:get_bucket(Bucket),
+ Servers = proplists:get_value(servers, BucketConfig),
+ case proplists:get_value(type, BucketConfig) of
+ membase ->
+ %% Promote replicas of vbuckets on this node
+ Map = proplists:get_value(map, BucketConfig),
+ Map1 = promote_replicas(Map, [Node]),
+ case [I || {I, [undefined|_]} <- misc:enumerate(Map1, 0)] of
+ [] -> ok; % Phew!
+ MissingVBuckets ->
+ ?log_error("Lost data in ~p for ~w", [Bucket, MissingVBuckets]),
+ ns_log:log(?MODULE, 1,
+ "Data has been lost for ~B% of vbuckets in bucket ~p.",
+ [length(MissingVBuckets) * 100 div length(Map), Bucket])
+ end,
+ ns_bucket:set_map(Bucket, Map1),
+ ns_bucket:set_servers(Bucket, lists:delete(Node, Servers)),
+ ns_janitor:cleanup(Bucket);
+ memcached ->
+ ns_bucket:set_servers(Bucket, lists:delete(Node, Servers))
+ end.
generate_initial_map(NumReplicas, NumVBuckets, Servers) ->

0 comments on commit 44e0bc2

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