Fix silly-dumb errors in seal epoch comparisons
This commit is contained in:
parent
96b561cde9
commit
63d1c93fc9
3 changed files with 55 additions and 15 deletions
|
@ -186,12 +186,12 @@ handle_call({{read, _ClientEpoch, LogicalPN}, LC1}, _From, State) ->
|
||||||
{reply, {Reply, LC2}, State};
|
{reply, {Reply, LC2}, State};
|
||||||
|
|
||||||
handle_call({{seal, ClientEpoch}, LC1}, _From, #state{min_epoch=MinEpoch} = State)
|
handle_call({{seal, ClientEpoch}, LC1}, _From, #state{min_epoch=MinEpoch} = State)
|
||||||
when ClientEpoch =< MinEpoch ->
|
when ClientEpoch < MinEpoch ->
|
||||||
LC2 = lclock_update(LC1),
|
LC2 = lclock_update(LC1),
|
||||||
{reply, {error_badepoch, LC2}, State};
|
{reply, {error_badepoch, LC2}, State};
|
||||||
handle_call({{seal, ClientEpoch}, LC1}, _From, #state{max_logical_page=MLPN}=State) ->
|
handle_call({{seal, ClientEpoch}, LC1}, _From, #state{max_logical_page=MLPN}=State) ->
|
||||||
LC2 = lclock_update(LC1),
|
LC2 = lclock_update(LC1),
|
||||||
NewState = State#state{min_epoch=ClientEpoch},
|
NewState = State#state{min_epoch=ClientEpoch+1},
|
||||||
ok = write_hard_state(NewState),
|
ok = write_hard_state(NewState),
|
||||||
{reply, {{ok, MLPN}, LC2}, NewState};
|
{reply, {{ok, MLPN}, LC2}, NewState};
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ basic_test() ->
|
||||||
try
|
try
|
||||||
Epoch1 = 1,
|
Epoch1 = 1,
|
||||||
Epoch2 = 2,
|
Epoch2 = 2,
|
||||||
|
Epoch3 = 3,
|
||||||
LPN = 1,
|
LPN = 1,
|
||||||
Bin1 = <<42:64>>,
|
Bin1 = <<42:64>>,
|
||||||
Bin2 = <<42042:64>>,
|
Bin2 = <<42042:64>>,
|
||||||
|
@ -71,13 +72,13 @@ basic_test() ->
|
||||||
0 = ?M:get__min_epoch(P1),
|
0 = ?M:get__min_epoch(P1),
|
||||||
0 = ?M:get__trim_watermark(P1),
|
0 = ?M:get__trim_watermark(P1),
|
||||||
{ok, LPN} = ?M:seal(P1, Epoch1),
|
{ok, LPN} = ?M:seal(P1, Epoch1),
|
||||||
1 = ?M:get__min_epoch(P1),
|
2 = ?M:get__min_epoch(P1),
|
||||||
|
|
||||||
error_overwritten = ?M:write(P1, Epoch2, LPN, Bin1),
|
error_overwritten = ?M:write(P1, Epoch2, LPN, Bin1),
|
||||||
ok = ?M:write(P1, Epoch2, LPN+1, Bin2),
|
ok = ?M:write(P1, Epoch2, LPN+1, Bin2),
|
||||||
Epoch1 = ?M:get__min_epoch(P1),
|
Epoch2 = ?M:get__min_epoch(P1),
|
||||||
|
|
||||||
{ok, Bin1} = ?M:read(P1, Epoch1, LPN),
|
error_badepoch = ?M:read(P1, Epoch1, LPN),
|
||||||
{ok, Bin2} = ?M:read(P1, Epoch2, LPN+1),
|
{ok, Bin2} = ?M:read(P1, Epoch2, LPN+1),
|
||||||
error_unwritten = ?M:read(P1, Epoch2, LPN+2),
|
error_unwritten = ?M:read(P1, Epoch2, LPN+2),
|
||||||
badarg = ?M:read(P1, Epoch2, 1 bsl 2982),
|
badarg = ?M:read(P1, Epoch2, 1 bsl 2982),
|
||||||
|
@ -88,23 +89,23 @@ basic_test() ->
|
||||||
|
|
||||||
error_badepoch = ?M:read(P1, Epoch1, LPN),
|
error_badepoch = ?M:read(P1, Epoch1, LPN),
|
||||||
error_badepoch = ?M:read(P1, Epoch1, LPN+1),
|
error_badepoch = ?M:read(P1, Epoch1, LPN+1),
|
||||||
{ok, Bin1} = ?M:read(P1, Epoch2, LPN),
|
{ok, Bin1} = ?M:read(P1, Epoch3, LPN),
|
||||||
{ok, Bin2} = ?M:read(P1, Epoch2, LPN+1),
|
{ok, Bin2} = ?M:read(P1, Epoch3, LPN+1),
|
||||||
|
|
||||||
error_badepoch = ?M:trim(P1, Epoch1, LPN+1),
|
error_badepoch = ?M:trim(P1, Epoch1, LPN+1),
|
||||||
ok = ?M:trim(P1, Epoch2, LPN+1),
|
ok = ?M:trim(P1, Epoch3, LPN+1),
|
||||||
error_trimmed = ?M:trim(P1, Epoch2, LPN+1),
|
error_trimmed = ?M:trim(P1, Epoch3, LPN+1),
|
||||||
%% Current watermark processing is broken. But we'll test what's
|
%% Current watermark processing is broken. But we'll test what's
|
||||||
%% there now.
|
%% there now.
|
||||||
ExpectedWaterFixMe = LPN+1,
|
ExpectedWaterFixMe = LPN+1,
|
||||||
ExpectedWaterFixMe = ?M:get__trim_watermark(P1),
|
ExpectedWaterFixMe = ?M:get__trim_watermark(P1),
|
||||||
|
|
||||||
ok = ?M:fill(P1, Epoch2, LPN+3),
|
ok = ?M:fill(P1, Epoch3, LPN+3),
|
||||||
error_trimmed = ?M:read(P1, Epoch2, LPN+3),
|
error_trimmed = ?M:read(P1, Epoch3, LPN+3),
|
||||||
error_trimmed = ?M:fill(P1, Epoch2, LPN+3),
|
error_trimmed = ?M:fill(P1, Epoch3, LPN+3),
|
||||||
error_trimmed = ?M:trim(P1, Epoch2, LPN+3),
|
error_trimmed = ?M:trim(P1, Epoch3, LPN+3),
|
||||||
|
|
||||||
Epoch2 = ?M:get__min_epoch(P1),
|
Epoch3 = ?M:get__min_epoch(P1),
|
||||||
ok = ?M:stop(P1),
|
ok = ?M:stop(P1),
|
||||||
ok
|
ok
|
||||||
after
|
after
|
||||||
|
@ -117,7 +118,7 @@ seal_persistence_test() ->
|
||||||
try
|
try
|
||||||
0 = ?M:get__min_epoch(P1),
|
0 = ?M:get__min_epoch(P1),
|
||||||
Epoch = 665,
|
Epoch = 665,
|
||||||
{ok, LPN} = ?M:seal(P1, Epoch),
|
{ok, LPN} = ?M:seal(P1, Epoch-1),
|
||||||
Epoch = ?M:get__min_epoch(P1),
|
Epoch = ?M:get__min_epoch(P1),
|
||||||
ok = ?M:stop(P1),
|
ok = ?M:stop(P1),
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,45 @@ smoke1_test() ->
|
||||||
setup_del_all(NumFLUs)
|
setup_del_all(NumFLUs)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
smoke_append_badepoch_test() ->
|
||||||
|
PDir = "./tmp.smoke2.projection",
|
||||||
|
NumFLUs = 6,
|
||||||
|
PageSize = 8,
|
||||||
|
NumPages = 10,
|
||||||
|
FLUs = [F1, F2, F3, F4, F5, F6] =
|
||||||
|
setup_basic_flus(NumFLUs, PageSize, NumPages),
|
||||||
|
{ok, Seq} = corfurl_sequencer:start_link(FLUs),
|
||||||
|
|
||||||
|
%% We know that the first LPN will be 1.
|
||||||
|
LPN_Pgs = [{X, list_to_binary(
|
||||||
|
lists:flatten(io_lib:format("~8..0w", [X])))} ||
|
||||||
|
X <- lists:seq(1, 5)],
|
||||||
|
try
|
||||||
|
LittleEpoch = 4,
|
||||||
|
BigEpoch = 42,
|
||||||
|
P0 = ?M:new_simple_projection(PDir, BigEpoch, 1, 1*100,
|
||||||
|
[[F1, F2, F3], [F4, F5, F6]]),
|
||||||
|
P1 = P0#proj{seq={Seq, unused, unused}},
|
||||||
|
[begin {{ok, LPN}, _} = corfurl_client:append_page(P1, Pg) end || {LPN, Pg} <- LPN_Pgs],
|
||||||
|
|
||||||
|
[{ok, _} = corfurl_flu:seal(FLU, BigEpoch) || FLU <- FLUs],
|
||||||
|
[begin
|
||||||
|
{error_badepoch, _} = corfurl_client:append_page(P1, Pg)
|
||||||
|
end || {_LPN, Pg} <- LPN_Pgs],
|
||||||
|
|
||||||
|
P2 = P1#proj{epoch=LittleEpoch},
|
||||||
|
[begin
|
||||||
|
{error_badepoch, _} = corfurl_client:append_page(P2, Pg)
|
||||||
|
end || {_LPN, Pg} <- LPN_Pgs],
|
||||||
|
|
||||||
|
ok
|
||||||
|
after
|
||||||
|
corfurl_util:delete_dir(PDir),
|
||||||
|
corfurl_sequencer:stop(Seq),
|
||||||
|
[corfurl_flu:stop(F) || F <- FLUs],
|
||||||
|
setup_del_all(NumFLUs)
|
||||||
|
end.
|
||||||
|
|
||||||
-ifdef(TIMING_TEST).
|
-ifdef(TIMING_TEST).
|
||||||
|
|
||||||
forfun_test_() ->
|
forfun_test_() ->
|
||||||
|
|
Loading…
Reference in a new issue