Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Flush buckets that are no longer mapped to this node as well.

Change-Id: Ia25c82a577aa907d30605e6d1e7cf6ef08bd5cee
Reviewed-on: http://review.northscale.com/3187
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
commit 18829ab63d08d38e75bc119f6f7772ea5ea1943c 1 parent 6288bff
@seanlynch seanlynch authored alk committed
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/ns_memcached.erl
View
14 src/ns_memcached.erl
@@ -182,8 +182,16 @@ terminate(Reason, #state{bucket=Bucket, sock=Sock}) ->
not_present ->
?log_info("Flushing data for deleted bucket ~p", [Bucket]),
mc_client_binary:flush(Sock);
- _ ->
- ok
+ {ok, BucketConfig} ->
+ case lists:member(node(), proplists:get_value(
+ servers, BucketConfig)) of
+ true ->
+ ok;
+ false ->
+ ?log_info("Flushing data for bucket ~p since we no longer own it.",
+ [Bucket]),
+ mc_client_binary:flush(Sock)
+ end
end,
?log_info("Shutting down bucket ~p", [Bucket]),
try
@@ -331,6 +339,8 @@ ensure_bucket(Sock, Bucket) ->
ok = mc_client_binary:select_bucket(Sock, Bucket);
{memcached_error, key_eexists, <<"Bucket exists: stopping">>} ->
%% Waiting for an old bucket with this name to shut down
+ ?log_info("Waiting for ~p to finish shutting down before we start it.",
+ [Bucket]),
timer:sleep(1000),
ensure_bucket(Sock, Bucket);
Error ->
Please sign in to comment.
Something went wrong with that request. Please try again.