diff --git a/src/leveled_cdb.erl b/src/leveled_cdb.erl index 8fd2fe5..bcd4f05 100644 --- a/src/leveled_cdb.erl +++ b/src/leveled_cdb.erl @@ -266,6 +266,13 @@ writer({put_kv, Key, Value}, _From, State) -> %% Key and value could not be written {reply, roll, writer, State}; {UpdHandle, NewPosition, HashTree} -> + ok = + case State#state.sync_strategy of + riak_sync -> + file:datasync(UpdHandle); + _ -> + ok + end, {reply, ok, writer, State#state{handle=UpdHandle, last_position=NewPosition, last_key=Key, @@ -525,17 +532,17 @@ code_change(_OldVsn, StateName, State, _Extra) -> %% Assumption is that sync should be used - it is a transaction log. %% -%% When running the Riak-specific version on Erlang 16, it sets the sync flag -%% using the o_sync keyword (as it is in posix). If using a non-Basho OTP 16 -%% sync is not possible so none will need to be passed. This is not -%% recommended, but is allowed here to make it simpler to test against -%% off-the-shelf OTP 16 +%% However this flag is not supported in OTP 16. Bitcask appears to pass an +%% o_sync flag, but this isn't supported either (maybe it works with the +%% bitcask nif fileops). +%% +%% To get round this will try and datasync on each PUT with riak_sync set_writeops(SyncStrategy) -> case SyncStrategy of sync -> [sync | ?WRITE_OPS]; riak_sync -> - [o_sync | ?WRITE_OPS]; + ?WRITE_OPS; none -> ?WRITE_OPS end. @@ -1887,9 +1894,6 @@ crc_corrupt_writer_test() -> ?assertMatch({"Key100", "Value100"}, cdb_get(P2, "Key100")), ok = cdb_close(P2). -riak_writeops_test() -> - ?assertMatch([o_sync, binary, raw, read, write], set_writeops(riak_sync)). - nonsense_coverage_test() -> {ok, Pid} = gen_fsm:start(?MODULE, [#cdb_options{}], []), ok = gen_fsm:send_all_state_event(Pid, nonsense), diff --git a/src/leveled_skiplist.erl b/src/leveled_skiplist.erl index 21ce6f5..eb490ee 100644 --- a/src/leveled_skiplist.erl +++ b/src/leveled_skiplist.erl @@ -348,18 +348,22 @@ skiplist_timingtest(KL, SkipList) -> ?assertMatch(KL, FlatList). define_kv(X) -> - {{o, "Bucket", "Key" ++ X, null}, {X, {active, infinity}, null}}. + {{o, "Bucket", "Key" ++ string:right(integer_to_list(X), 6), null}, + {X, {active, infinity}, null}}. skiplist_roundsize_test() -> - KVL = lists:map(fun(X) -> define_kv(X) end, lists:seq(1, 800)), + KVL = lists:map(fun(X) -> define_kv(X) end, lists:seq(1, 4000)), SkipList = from_list(KVL), lists:foreach(fun({K, V}) -> ?assertMatch({value, V}, lookup(K, SkipList)) end, KVL), - lists:foreach(fun(X) -> R = to_range(SkipList, - define_kv(X * 32 + 1), - define_kv((X + 1) * 32)), - L = lists:sublist(KVL, X * 32 + 1, 32), + lists:foreach(fun(X) -> + {KS, _VS} = define_kv(X * 32 + 1), + {KE, _VE} = define_kv((X + 1) * 32), + R = to_range(SkipList, KS, KE), + L = lists:sublist(KVL, + X * 32 + 1, + 32), ?assertMatch(L, R) end, lists:seq(0, 24)). diff --git a/test/end_to_end/basic_SUITE.erl b/test/end_to_end/basic_SUITE.erl index c83513d..c36246d 100644 --- a/test/end_to_end/basic_SUITE.erl +++ b/test/end_to_end/basic_SUITE.erl @@ -70,7 +70,7 @@ many_put_fetch_head(_Config) -> RootPath = testutil:reset_filestructure(), StartOpts1 = [{root_path, RootPath}, {max_pencillercachesize, 16000}, - {sync_strategy, testutil:sync_strategy()}], + {sync_strategy, riak_sync}], {ok, Bookie1} = leveled_bookie:book_start(StartOpts1), {TestObject, TestSpec} = testutil:generate_testobject(), ok = testutil:book_riakput(Bookie1, TestObject, TestSpec),