Datasync added for riak_sync strategy
This commit is contained in:
parent
2fdf70ddf6
commit
45f7fcb41a
3 changed files with 24 additions and 16 deletions
|
@ -266,6 +266,13 @@ writer({put_kv, Key, Value}, _From, State) ->
|
||||||
%% Key and value could not be written
|
%% Key and value could not be written
|
||||||
{reply, roll, writer, State};
|
{reply, roll, writer, State};
|
||||||
{UpdHandle, NewPosition, HashTree} ->
|
{UpdHandle, NewPosition, HashTree} ->
|
||||||
|
ok =
|
||||||
|
case State#state.sync_strategy of
|
||||||
|
riak_sync ->
|
||||||
|
file:datasync(UpdHandle);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
{reply, ok, writer, State#state{handle=UpdHandle,
|
{reply, ok, writer, State#state{handle=UpdHandle,
|
||||||
last_position=NewPosition,
|
last_position=NewPosition,
|
||||||
last_key=Key,
|
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.
|
%% 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
|
%% However this flag is not supported in OTP 16. Bitcask appears to pass an
|
||||||
%% using the o_sync keyword (as it is in posix). If using a non-Basho OTP 16
|
%% o_sync flag, but this isn't supported either (maybe it works with the
|
||||||
%% sync is not possible so none will need to be passed. This is not
|
%% bitcask nif fileops).
|
||||||
%% recommended, but is allowed here to make it simpler to test against
|
%%
|
||||||
%% off-the-shelf OTP 16
|
%% To get round this will try and datasync on each PUT with riak_sync
|
||||||
set_writeops(SyncStrategy) ->
|
set_writeops(SyncStrategy) ->
|
||||||
case SyncStrategy of
|
case SyncStrategy of
|
||||||
sync ->
|
sync ->
|
||||||
[sync | ?WRITE_OPS];
|
[sync | ?WRITE_OPS];
|
||||||
riak_sync ->
|
riak_sync ->
|
||||||
[o_sync | ?WRITE_OPS];
|
?WRITE_OPS;
|
||||||
none ->
|
none ->
|
||||||
?WRITE_OPS
|
?WRITE_OPS
|
||||||
end.
|
end.
|
||||||
|
@ -1887,9 +1894,6 @@ crc_corrupt_writer_test() ->
|
||||||
?assertMatch({"Key100", "Value100"}, cdb_get(P2, "Key100")),
|
?assertMatch({"Key100", "Value100"}, cdb_get(P2, "Key100")),
|
||||||
ok = cdb_close(P2).
|
ok = cdb_close(P2).
|
||||||
|
|
||||||
riak_writeops_test() ->
|
|
||||||
?assertMatch([o_sync, binary, raw, read, write], set_writeops(riak_sync)).
|
|
||||||
|
|
||||||
nonsense_coverage_test() ->
|
nonsense_coverage_test() ->
|
||||||
{ok, Pid} = gen_fsm:start(?MODULE, [#cdb_options{}], []),
|
{ok, Pid} = gen_fsm:start(?MODULE, [#cdb_options{}], []),
|
||||||
ok = gen_fsm:send_all_state_event(Pid, nonsense),
|
ok = gen_fsm:send_all_state_event(Pid, nonsense),
|
||||||
|
|
|
@ -348,18 +348,22 @@ skiplist_timingtest(KL, SkipList) ->
|
||||||
?assertMatch(KL, FlatList).
|
?assertMatch(KL, FlatList).
|
||||||
|
|
||||||
define_kv(X) ->
|
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() ->
|
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),
|
SkipList = from_list(KVL),
|
||||||
lists:foreach(fun({K, V}) ->
|
lists:foreach(fun({K, V}) ->
|
||||||
?assertMatch({value, V}, lookup(K, SkipList)) end,
|
?assertMatch({value, V}, lookup(K, SkipList)) end,
|
||||||
KVL),
|
KVL),
|
||||||
lists:foreach(fun(X) -> R = to_range(SkipList,
|
lists:foreach(fun(X) ->
|
||||||
define_kv(X * 32 + 1),
|
{KS, _VS} = define_kv(X * 32 + 1),
|
||||||
define_kv((X + 1) * 32)),
|
{KE, _VE} = define_kv((X + 1) * 32),
|
||||||
L = lists:sublist(KVL, X * 32 + 1, 32),
|
R = to_range(SkipList, KS, KE),
|
||||||
|
L = lists:sublist(KVL,
|
||||||
|
X * 32 + 1,
|
||||||
|
32),
|
||||||
?assertMatch(L, R) end,
|
?assertMatch(L, R) end,
|
||||||
lists:seq(0, 24)).
|
lists:seq(0, 24)).
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ many_put_fetch_head(_Config) ->
|
||||||
RootPath = testutil:reset_filestructure(),
|
RootPath = testutil:reset_filestructure(),
|
||||||
StartOpts1 = [{root_path, RootPath},
|
StartOpts1 = [{root_path, RootPath},
|
||||||
{max_pencillercachesize, 16000},
|
{max_pencillercachesize, 16000},
|
||||||
{sync_strategy, testutil:sync_strategy()}],
|
{sync_strategy, riak_sync}],
|
||||||
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
||||||
{TestObject, TestSpec} = testutil:generate_testobject(),
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
||||||
ok = testutil:book_riakput(Bookie1, TestObject, TestSpec),
|
ok = testutil:book_riakput(Bookie1, TestObject, TestSpec),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue