Fix handling of {error, partial_read}

This commit is contained in:
Scott Lystig Fritchie 2015-05-21 15:12:46 +09:00
parent 0d05efedb6
commit 7ba962e9fb
3 changed files with 9 additions and 4 deletions

View file

@ -95,7 +95,7 @@ copy the output files to machine **Y** and generate the graphs there.
## Compiling the Machi source ## Compiling the Machi source
First, clone the `basho_bench` source code, then compile it. You will First, clone the Machi source code, then compile it. You will
need Erlang/OTP version 17.x to compile. need Erlang/OTP version 17.x to compile.
cd /some/nice/dev/place cd /some/nice/dev/place

View file

@ -405,6 +405,8 @@ do_read_chunk2(File, Offset, Size, Depth, STime,
{ok, BadChunk} -> {ok, BadChunk} ->
exit({todo, bad_chunk_size, ?MODULE, ?LINE, File, Offset, Size, exit({todo, bad_chunk_size, ?MODULE, ?LINE, File, Offset, Size,
got, byte_size(BadChunk)}); got, byte_size(BadChunk)});
{error, partial_read}=Err ->
{reply, Err, S};
{error, Retry} {error, Retry}
when Retry == partition; Retry == bad_epoch; Retry == wedged -> when Retry == partition; Retry == bad_epoch; Retry == wedged ->
do_read_chunk(File, Offset, Size, Depth, STime, S); do_read_chunk(File, Offset, Size, Depth, STime, S);

View file

@ -35,7 +35,7 @@ smoke_test() ->
Prefix = <<"pre">>, Prefix = <<"pre">>,
Chunk1 = <<"yochunk">>, Chunk1 = <<"yochunk">>,
Host = "localhost", Host = "localhost",
PortBase = 4444, PortBase = 64444,
Os = [{ignore_stability_time, true}, {active_mode, false}], Os = [{ignore_stability_time, true}, {active_mode, false}],
{ok,_}=machi_flu_psup:start_flu_package(a, PortBase+0, "./data.a", Os), {ok,_}=machi_flu_psup:start_flu_package(a, PortBase+0, "./data.a", Os),
{ok,_}=machi_flu_psup:start_flu_package(b, PortBase+1, "./data.b", Os), {ok,_}=machi_flu_psup:start_flu_package(b, PortBase+1, "./data.b", Os),
@ -84,7 +84,6 @@ smoke_test() ->
%% Whew ... ok, now start some damn tests. %% Whew ... ok, now start some damn tests.
{ok, C1} = machi_cr_client:start_link([P || {_,P}<-orddict:to_list(D)]), {ok, C1} = machi_cr_client:start_link([P || {_,P}<-orddict:to_list(D)]),
machi_cr_client:append_chunk(C1, Prefix, Chunk1), machi_cr_client:append_chunk(C1, Prefix, Chunk1),
%% {machi_flu_psup:stop_flu_package(c), timer:sleep(50)},
{ok, {Off1,Size1,File1}} = {ok, {Off1,Size1,File1}} =
machi_cr_client:append_chunk(C1, Prefix, Chunk1), machi_cr_client:append_chunk(C1, Prefix, Chunk1),
{ok, Chunk1} = machi_cr_client:read_chunk(C1, File1, Off1, Size1), {ok, Chunk1} = machi_cr_client:read_chunk(C1, File1, Off1, Size1),
@ -119,7 +118,11 @@ smoke_test() ->
Host, PortBase+X, EpochID, Host, PortBase+X, EpochID,
File1, FooOff2, Size2)} || X <- [0,1,2] ], File1, FooOff2, Size2)} || X <- [0,1,2] ],
%% Misc API smoke %% Misc API smoke & minor regression checks
{error, not_written} = machi_cr_client:read_chunk(C1, <<"no">>,
999999999, 1),
{error, partial_read} = machi_cr_client:read_chunk(C1, File1,
Off1, 88888888),
%% Checksum lists are 3-tuples %% Checksum lists are 3-tuples
{ok, [{_,_,_}|_]} = machi_cr_client:checksum_list(C1, File1), {ok, [{_,_,_}|_]} = machi_cr_client:checksum_list(C1, File1),
{error, no_such_file} = machi_cr_client:checksum_list(C1, <<"!!!!">>), {error, no_such_file} = machi_cr_client:checksum_list(C1, <<"!!!!">>),