Skip to content
Browse files

Merge tag '1.6.1' into 1.6

Tag bitcask 1.6.1
  • Loading branch information...
2 parents 61f72bf + fbbf11e commit 025b987915591753b550a2e035b3afd2d8310e76 @jaredmorrow jaredmorrow committed May 10, 2013
Showing with 51 additions and 32 deletions.
  1. +1 −1 src/bitcask.app.src
  2. +10 −5 src/bitcask.erl
  3. +13 −7 src/bitcask_merge_delete.erl
  4. +6 −5 test/bitcask_qc.erl
  5. +17 −11 test/bitcask_qc_expiry.erl
  6. +4 −3 test/bitcask_qc_fsm.erl
View
2 src/bitcask.app.src
@@ -1,7 +1,7 @@
{application, bitcask,
[
{description, ""},
- {vsn, "1.6.0"},
+ {vsn, "1.6.1"},
{modules, []},
{registered, []},
{applications, [
View
15 src/bitcask.erl
@@ -111,8 +111,6 @@ open(Dirname, Opts) ->
%% and loading anyway: if later someone tries to write
%% something, that someone will get a write_locked exception.
_ = bitcask_lockops:delete_stale_lock(write, Dirname),
- %% This purge will acquire the write lock prior to doing anything.
- purge_setuid_files(Dirname),
fresh;
false -> undefined
end,
@@ -124,7 +122,7 @@ open(Dirname, Opts) ->
WaitTime = timer:seconds(get_opt(open_timeout, Opts)),
%% Loop and wait for the keydir to come available.
- case init_keydir(Dirname, WaitTime) of
+ case init_keydir(Dirname, WaitTime, WritingFile /= undefined) of
{ok, KeyDir, ReadFiles} ->
%% Ensure that expiry_secs is in Opts and not just application env
ExpOpts = [{expiry_secs,get_opt(expiry_secs,Opts)}|Opts],
@@ -877,7 +875,7 @@ scan_key_files([Filename | Rest], KeyDir, Acc, CloseFile, EnoentOK) ->
%%
%% Initialize a keydir for a given directory.
%%
-init_keydir(Dirname, WaitTime) ->
+init_keydir(Dirname, WaitTime, ReadWriteModeP) ->
%% Get the named keydir for this directory. If we get it and it's already
%% marked as ready, that indicates another caller has already loaded
%% all the data from disk and we can short-circuit scanning all the files.
@@ -903,6 +901,13 @@ init_keydir(Dirname, WaitTime) ->
Lock = poll_for_merge_lock(Dirname),
try
poll_deferred_delete_queue_empty(),
+ if ReadWriteModeP ->
+ %% This purge will acquire the write lock
+ %% prior to doing anything.
+ purge_setuid_files(Dirname);
+ true ->
+ ok
+ end,
init_keydir_scan_key_files(Dirname, KeyDir)
after
ok = bitcask_lockops:release(Lock)
@@ -919,7 +924,7 @@ init_keydir(Dirname, WaitTime) ->
Value when is_integer(Value), Value =< 0 -> %% avoids 'infinity'!
{error, timeout};
_ ->
- init_keydir(Dirname, WaitTime - 100)
+ init_keydir(Dirname, WaitTime - 100, ReadWriteModeP)
end
end.
View
20 src/bitcask_merge_delete.erl
@@ -138,7 +138,7 @@ delete_files(Files) ->
-ifdef(TEST).
multiple_merges_during_fold_test_() ->
- {timeout, 10, fun multiple_merges_during_fold_test_body/0}.
+ {timeout, 60, fun multiple_merges_during_fold_test_body/0}.
multiple_merges_during_fold_test_body() ->
Dir = "/tmp/bc.multiple-merges-fold",
@@ -166,15 +166,11 @@ multiple_merges_during_fold_test_body() ->
bitcask:has_setuid_bit(F)])
end,
PutSome(),
- bitcask:merge(Dir),
- Count1 = CountSetuids(),
- true = (Count1 > 0),
+ Count1 = merge_until(Dir, 0, CountSetuids),
PutSome(),
bitcask:merge(Dir),
PutSome(),
- bitcask:merge(Dir),
- Count2 = CountSetuids(),
- true = (Count2 > Count1),
+ merge_until(Dir, Count1, CountSetuids),
SlowPid ! go_ahead,
timer:sleep(500),
@@ -183,4 +179,14 @@ multiple_merges_during_fold_test_body() ->
ok.
+merge_until(Dir, MinCount, CountSetuids) ->
+ bitcask:merge(Dir),
+ Count = CountSetuids(),
+ if (Count > MinCount) ->
+ Count;
+ true ->
+ timer:sleep(100),
+ merge_until(Dir, MinCount, CountSetuids)
+ end.
+
-endif. %% TEST
View
11 test/bitcask_qc.erl
@@ -31,14 +31,15 @@
-define(QC_OUT(P),
eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
+-define(TEST_TIME, 30). % seconds
-record(m_fstats, {key_bytes=0, live_keys=0, live_bytes=0, total_keys=0, total_bytes=0}).
qc(P) ->
- qc(P, 100).
+ qc(P, ?TEST_TIME).
-qc(P, NumTests) ->
- ?assert(eqc:quickcheck(?QC_OUT(eqc:numtests(NumTests, P)))).
+qc(P, TestTime) ->
+ ?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(TestTime, P)))).
keys() ->
eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
@@ -263,7 +264,7 @@ prop_fold() ->
prop_merge_test_() ->
- {timeout, 300*60, fun() -> qc(prop_merge()) end}.
+ {timeout, ?TEST_TIME*2, fun() -> qc(prop_merge()) end}.
merge1_test() ->
?assert(eqc:check(prop_merge(),
@@ -281,7 +282,7 @@ merge3_test() ->
1,1}])).
prop_fold_test_() ->
- {timeout, 300*60, fun() -> qc(prop_fold()) end}.
+ {timeout, ?TEST_TIME*2, fun() -> qc(prop_fold()) end}.
get_keydir(Ref) ->
View
28 test/bitcask_qc_expiry.erl
@@ -31,12 +31,13 @@
-define(QC_OUT(P),
eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
+-define(TEST_TIME, 30). % seconds
qc(P) ->
- qc(P, 100).
+ qc(P, ?TEST_TIME).
-qc(P, NumTests) ->
- ?assert(eqc:quickcheck(?QC_OUT(eqc:numtests(NumTests, P)))).
+qc(P, TestTime) ->
+ ?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(TestTime, P)))).
keys() ->
eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
@@ -89,6 +90,7 @@ prop_expiry() ->
?FORALL({Ops, Expiry, ExpiryGrace, Timestep, M1},
{eqc_gen:non_empty(list(ops(Keys, Values))),
choose(1,10), choose(1, 10), choose(5, 50), choose(5,128)},
+ ?IMPLIES(length(Ops) > 1,
begin
Dirname = "/tmp/bc.prop.expiry",
?cmd("rm -rf " ++ Dirname),
@@ -130,24 +132,28 @@ prop_expiry() ->
%% Check that needs_merge has expected result
case Expired of
[] ->
- ?assertEqual(false, bitcask:needs_merge(Bref));
+ ?assertEqual(false, bitcask:needs_merge(Bref)),
+ true;
_ ->
- ?assertMatch({true, _}, bitcask:needs_merge(Bref))
+ ?assertMatch({true, _}, bitcask:needs_merge(Bref)),
+ true
end
- catch X:Y -> io:format(user, "exception: ~p ~p @ ~p\n", [X,Y, erlang:get_stacktrace()])
+ catch
+ X:Y ->
+ io:format(user, "exception: ~p ~p @ ~p\n",
+ [X,Y, erlang:get_stacktrace()])
after
bitcask:close(Bref)
- end,
- true
- end)).
+ end
+ end))).
prop_expiry_test_() ->
- {timeout, 300*60, fun() ->
+ {timeout, ?TEST_TIME*2, fun() ->
try
meck:new(bitcask_time, [passthrough]),
meck:expect(bitcask_time, tstamp, fun next_tstamp/0),
- qc(prop_expiry(), 500)
+ qc(prop_expiry())
after
meck:unload()
end
View
7 test/bitcask_qc_fsm.erl
@@ -108,10 +108,11 @@ postcondition(_From,_To,_S,{call,_,_,_},_Res) ->
true.
qc_test_() ->
- {timeout, 120,
+ TestTime = 45,
+ {timeout, TestTime*2,
{setup, fun prepare/0, fun cleanup/1,
- [{timeout, 120, ?_assertEqual(true,
- eqc:quickcheck(?QC_OUT(prop_bitcask())))}]}}.
+ [{timeout, TestTime*2, ?_assertEqual(true,
+ eqc:quickcheck(eqc:testing_time(TestTime, ?QC_OUT(prop_bitcask()))))}]}}.
prepare() ->
application:load(bitcask),

0 comments on commit 025b987

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