Fix proj0_test for concuerror, yay!

This commit is contained in:
Scott Lystig Fritchie 2014-10-15 12:42:43 +09:00
parent e50e669b79
commit 4969e019b2

View file

@ -109,7 +109,7 @@ wedge_test() ->
error_trimmed = m_trim(F1, Epoch2), error_trimmed = m_trim(F1, Epoch2),
ok = m_stop(F1), ok = m_stop(F1),
_XX = event_get_all(), io:format(user, "XX ~p\n", [_XX]), _XX = event_get_all(), %% io:format(user, "XX ~p\n", [_XX]),
event_shutdown(), event_shutdown(),
ok. ok.
@ -134,7 +134,8 @@ proj0_test() ->
SecondProj = machi_flu0:make_proj(2, FLUs), SecondProj = machi_flu0:make_proj(2, FLUs),
Epoch2 = SecondProj#proj.epoch, Epoch2 = SecondProj#proj.epoch,
Pid2 = spawn(fun() -> Pid2 = spawn(fun() ->
[ok = m_proj_write(F, Epoch2, SecondProj) || F <- FLUs], [ok = m_proj_write_with_check(F, Epoch2, SecondProj) ||
F <- FLUs],
Me ! {self(), done} Me ! {self(), done}
end), end),
Pids = [Pid1, Pid2], Pids = [Pid1, Pid2],
@ -142,7 +143,7 @@ proj0_test() ->
[receive {Pid, _} -> ok end || Pid <- Pids], [receive {Pid, _} -> ok end || Pid <- Pids],
[ok = m_stop(F) || F <- FLUs], [ok = m_stop(F) || F <- FLUs],
_XX = event_get_all(), %% io:format(user, "XX ~p\n", [_XX]), _XX = event_get_all(), %%io:format(user, "XX ~p\n", [_XX]),
event_shutdown(), event_shutdown(),
ok. ok.
@ -173,6 +174,21 @@ m_proj_write(Pid, Epoch, Proj) ->
event_add(proj_write, Pid, Res), event_add(proj_write, Pid, Res),
Res. Res.
m_proj_write_with_check(Pid, Epoch, Proj) ->
case m_proj_write(Pid, Epoch, Proj) of
ok ->
ok;
error_written ->
case m_proj_read(Pid, Epoch) of
{ok, Proj} ->
ok;
{ok, OtherProj} ->
{bummer, other_proj, OtherProj};
Else ->
Else
end
end.
m_proj_read(Pid, Epoch) -> m_proj_read(Pid, Epoch) ->
Res = machi_flu0:proj_read(Pid, Epoch), Res = machi_flu0:proj_read(Pid, Epoch),
event_add(proj_read, Pid, Res), event_add(proj_read, Pid, Res),
@ -209,8 +225,7 @@ m_append_page(Proj, Bytes, Retries) ->
{error_stale_projection, _} -> {error_stale_projection, _} ->
Retry(); Retry();
error_wedged -> error_wedged ->
TODO left off here: read-repair the projection store across all youbetcha = m_repair_projection_store(Proj),
participants, then retry.............
Retry(); Retry();
Else -> Else ->
{Else, Proj} {Else, Proj}
@ -294,6 +309,12 @@ multi_call([H|T], Mod, Fun, ArgSuffix) ->
multi_call(T, Mod, Fun, ArgSuffix) multi_call(T, Mod, Fun, ArgSuffix)
end. end.
m_repair_projection_store(Proj) ->
[begin
catch m_proj_write(FLU, Proj#proj.epoch, Proj)
end || FLU <- Proj#proj.all],
youbetcha.
%%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%% %%%%
event_setup() -> event_setup() ->
@ -309,7 +330,9 @@ event_shutdown() ->
event_add(Key, Who, Description) -> event_add(Key, Who, Description) ->
Tab = ?MODULE, Tab = ?MODULE,
ets:insert(Tab, {lamport_clock:get(), Key, Who, Description}). E = {lamport_clock:get(), Key, Who, Description},
%%io:format(user, "E = ~p\n", [E]),
ets:insert(Tab, E).
event_get_all() -> event_get_all() ->
Tab = ?MODULE, Tab = ?MODULE,