Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1.2'

  • Loading branch information...
commit 6e63ed09267b8ddf3434853705162422910a5fc5 2 parents c6171f8 + 7bcedaa
@jaredmorrow jaredmorrow authored
View
45 src/riak_kv_bitcask_backend.erl
@@ -124,7 +124,12 @@ start(Partition, Config) ->
%% @doc Stop the bitcask backend
-spec stop(state()) -> ok.
stop(#state{ref=Ref}) ->
- bitcask:close(Ref).
+ case Ref of
+ undefined ->
+ ok;
+ _ ->
+ bitcask:close(Ref)
+ end.
%% @doc Retrieve an object from the bitcask backend
-spec get(riak_object:bucket(), riak_object:key(), state()) ->
@@ -304,8 +309,7 @@ fold_objects(FoldObjectsFun, Acc, Opts, #state{opts=BitcaskOpts,
-spec drop(state()) -> {ok, state()} | {error, term(), state()}.
drop(#state{ref=Ref,
partition=Partition,
- root=DataRoot,
- opts=BitcaskOpts}=State) ->
+ root=DataRoot}=State) ->
%% Close the bitcask reference
bitcask:close(Ref),
@@ -321,32 +325,17 @@ drop(#state{ref=Ref,
CleanupDir = check_for_cleanup_dir(DataRoot, auto),
move_unused_dirs(CleanupDir, PartitionDirs),
+ %% Spawn a process to cleanup the old data files.
+ %% The use of spawn is intentional. We do not
+ %% care if this process dies since any lingering
+ %% files will be cleaned up on the next drop.
+ %% The worst case is that the files hang
+ %% around and take up some disk space.
+ spawn(drop_data_cleanup(PartitionStr, CleanupDir)),
+
%% Make sure the data directory is now empty
data_directory_cleanup(PartitionDir),
-
- case make_data_dir(filename:join([DataRoot,
- PartitionStr])) of
- {ok, DataDir} ->
- %% Spawn a process to cleanup the old data files.
- %% The use of spawn is intentional. We do not
- %% care if this process dies since any lingering
- %% files will be cleaned up on the next drop.
- %% The worst case is that the files hang
- %% around and take up some disk space.
- spawn(drop_data_cleanup(PartitionStr, CleanupDir)),
-
- %% Now open the bitcask and return an updated state
- %% so this backend can continue processing.
- case bitcask:open(filename:join(DataRoot, DataDir), BitcaskOpts) of
- Ref1 when is_reference(Ref1) ->
- {ok, State#state{data_dir=DataDir,
- ref=Ref1}};
- {error, Reason} ->
- {error, Reason, State#state{data_dir=DataDir}}
- end;
- {error, Reason1} ->
- {error, Reason1, State}
- end.
+ {ok, State#state{ref = undefined}}.
%% @doc Returns true if this bitcasks backend contains any
%% non-tombstone values; otherwise returns false.
@@ -737,7 +726,7 @@ drop_test() ->
%% Stop the backend
ok = stop(State1),
os:cmd("rm -rf test/bitcask-backend/*"),
- ?assertEqual(["42", "auto_cleanup"], lists:sort(DataDirs)),
+ ?assertEqual(["auto_cleanup"], lists:sort(DataDirs)),
%% The drop cleanup happens in a separate process so
%% there is no guarantee it has happened yet when
%% this test runs.
View
16 src/riak_kv_eleveldb_backend.erl
@@ -106,8 +106,13 @@ start(Partition, Config) ->
%% @doc Stop the eleveldb backend
-spec stop(state()) -> ok.
-stop(_State) ->
- %% No-op; GC handles cleanup
+stop(State) ->
+ case State#state.ref of
+ undefined ->
+ ok;
+ _ ->
+ eleveldb:close(State#state.ref)
+ end,
ok.
%% @doc Retrieve an object from the eleveldb backend
@@ -280,12 +285,7 @@ drop(State0) ->
eleveldb:close(State0#state.ref),
case eleveldb:destroy(State0#state.data_root, []) of
ok ->
- case open_db(State0) of
- {ok, State} ->
- {ok, State};
- {error, Reason} ->
- {error, Reason, State0}
- end;
+ {ok, State0#state{ref = undefined}};
{error, Reason} ->
{error, Reason, State0}
end.
View
1  src/riak_kv_stat.erl
@@ -211,6 +211,7 @@ update(Arg) ->
%% gen_server
init([]) ->
+ register_stats(),
{ok, ok}.
handle_call(_Req, _From, State) ->
View
4 src/riak_kv_sup.erl
@@ -47,9 +47,6 @@ init([]) ->
{riak_core_vnode_master, start_link,
[riak_kv_vnode, riak_kv_legacy_vnode, riak_kv]},
permanent, 5000, worker, [riak_core_vnode_master]},
- RiakStat = {riak_kv_stat,
- {riak_kv_stat, start_link, []},
- permanent, 5000, worker, [riak_kv_stat]},
MapJSPool = {?JSPOOL_MAP,
{riak_kv_js_manager, start_link,
[?JSPOOL_MAP, read_js_pool_size(map_js_vm_count, "map")]},
@@ -114,7 +111,6 @@ init([]) ->
% Build the process list...
Processes = lists:flatten([
?IF(HasStorageBackend, VMaster, []),
- RiakStat,
GetFsmSup,
PutFsmSup,
DeleteSup,
View
10 src/riak_kv_wm_stats.erl
@@ -68,13 +68,7 @@ content_types_provided(ReqData, Context) ->
service_available(ReqData, Ctx) ->
- case app_helper:get_env(riak_kv, riak_kv_stat, false) of
- false ->
- {false, wrq:append_to_response_body("riak_kv_stat is disabled on this node.\n", ReqData),
- Ctx};
- true ->
- {true, ReqData, Ctx}
- end.
+ {true, ReqData, Ctx}.
forbidden(RD, Ctx) ->
{riak_kv_wm_utils:is_forbidden(RD), RD, Ctx}.
@@ -93,5 +87,3 @@ pretty_print(RD1, C1=#ctx{}) ->
get_stats() ->
proplists:delete(disk, riak_kv_stat:get_stats()) ++
riak_core_stat:get_stats().
-
-
View
20 test/backend_eqc.erl
@@ -249,12 +249,13 @@ init_backend(Backend, _Volatile, Config) ->
S.
drop(Backend, State) ->
- case Backend:drop(State) of
- {ok, NewState} ->
- NewState;
- {error, _, NewState} ->
- NewState
- end.
+ State1 = case Backend:drop(State) of
+ {ok, NewState} ->
+ NewState;
+ {error, _, NewState} ->
+ NewState
+ end,
+ Backend:stop(State1).
delete(Bucket, Key, Backend, BackendState, Indexes) ->
IndexSpecs = [{remove, Idx, SKey} || {B,Idx,SKey,K} <- Indexes,
@@ -349,9 +350,10 @@ next_state_data(_From, _To, S, _R, {call, _M, put, [Bucket, Key, IndexSpecs, Val
next_state_data(_From, _To, S, _R, {call, _M, delete, [Bucket, Key|_]}) ->
S#qcst{d = orddict:erase({Bucket, Key}, S#qcst.d),
i = remove_indexes(Bucket, Key, S#qcst.i)};
-next_state_data(_From, _To, S, R, {call, ?MODULE, drop, _}) ->
+next_state_data(_From, _To, S, _R, {call, ?MODULE, drop, _}) ->
+
S#qcst{d=orddict:new(),
- s=R,
+ s=undefined,
i=ordsets:new()};
next_state_data(_From, _To, S, _R, _C) ->
S.
@@ -373,7 +375,7 @@ running(#qcst{backend=Backend,
{history, {call, Backend, fold_keys, [fold_keys_fun(), get_fold_buffer(), fold_keys_opts(), State]}},
{history, {call, Backend, fold_objects, [fold_objects_fun(), get_fold_buffer(), g_opts(), State]}},
{history, {call, Backend, is_empty, [State]}},
- {history, {call, ?MODULE, drop, [Backend, State]}},
+ {stopped, {call, ?MODULE, drop, [Backend, State]}},
{stopped, {call, Backend, stop, [State]}}
].
Please sign in to comment.
Something went wrong with that request. Please try again.