From 58d840ef7ec821f4a1fd35878ad7527bbdedad1b Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Thu, 13 Aug 2015 18:43:41 +0900 Subject: [PATCH 1/3] Minor react changes, minor fix for return val of A50 --- src/machi_chain_manager1.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/machi_chain_manager1.erl b/src/machi_chain_manager1.erl index 213f780..4d46ef7 100644 --- a/src/machi_chain_manager1.erl +++ b/src/machi_chain_manager1.erl @@ -1281,11 +1281,12 @@ react_to_env_A40(Retries, P_newprop, P_latest, LatestUnanimousP, react_to_env_A50(P_latest, FinalProps, S) end. -react_to_env_A50(P_latest, FinalProps, S) -> +react_to_env_A50(P_latest, FinalProps, #ch_mgr{proj=P_current}=S) -> ?REACT(a50), - ?REACT({a50, ?LINE, [{latest_epoch, P_latest#projection_v1.epoch_number}, + ?REACT({a50, ?LINE, [{current_epoch, P_current#projection_v1.epoch_number}, + {latest_epoch, P_latest#projection_v1.epoch_number}, {final_props, FinalProps}]}), - {{no_change, FinalProps, P_latest#projection_v1.epoch_number}, S}. + {{no_change, FinalProps, P_current#projection_v1.epoch_number}, S}. react_to_env_B10(Retries, P_newprop, P_latest, LatestUnanimousP, Rank_newprop, Rank_latest, @@ -1543,6 +1544,7 @@ react_to_env_C103(#projection_v1{epoch_number=Epoch_latest, react_to_env_C110(P_latest, #ch_mgr{name=MyName} = S) -> ?REACT(c110), + ?REACT({c110, [{latest_epoch, P_latest#projection_v1.epoch_number}]}), Extra_todo = [{react,get(react)}], P_latest2 = machi_projection:update_dbg2(P_latest, Extra_todo), From 9768f3c0352ade86aa8a93ff62d919bb8e113bfc Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Thu, 13 Aug 2015 18:44:25 +0900 Subject: [PATCH 2/3] Projection store private write returns bad_arg if max_public_epochid is greater --- src/machi_projection_store.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/machi_projection_store.erl b/src/machi_projection_store.erl index 382d882..b75197d 100644 --- a/src/machi_projection_store.erl +++ b/src/machi_projection_store.erl @@ -261,7 +261,17 @@ do_proj_read(ProjType, Epoch, S_or_Dir) -> {{error, Else}, S_or_Dir} end. -do_proj_write(ProjType, #projection_v1{epoch_number=Epoch}=Proj, S) -> +do_proj_write(public=ProjType, Proj, S) -> + do_proj_write2(ProjType, Proj, S); +do_proj_write(private=ProjType, #projection_v1{epoch_number=Epoch}=Proj, S) -> + case S#state.max_public_epochid of + {PublicEpoch, _} when PublicEpoch =< Epoch -> + do_proj_write2(ProjType, Proj, S); + {PublicEpoch, _} -> + {{error, bad_arg}, S} + end. + +do_proj_write2(ProjType, #projection_v1{epoch_number=Epoch}=Proj, S) -> %% TODO: We probably ought to check the projection checksum for sanity, eh? Dir = pick_path(ProjType, S), Path = filename:join(Dir, epoch2name(Epoch)), From dcbc3b45ffe3ba58993feb450159b37666d14231 Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Thu, 13 Aug 2015 18:45:15 +0900 Subject: [PATCH 3/3] C110: handle proj store private write failure when conditional fails --- src/machi_chain_manager1.erl | 96 ++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/src/machi_chain_manager1.erl b/src/machi_chain_manager1.erl index 4d46ef7..4b64598 100644 --- a/src/machi_chain_manager1.erl +++ b/src/machi_chain_manager1.erl @@ -1559,53 +1559,26 @@ react_to_env_C110(P_latest, #ch_mgr{name=MyName} = S) -> case {?FLU_PC:write_projection(MyNamePid, private, P_latest2,?TO*30),Goo} of {ok, Goo} -> - ok; + ?REACT({c120, [{write, ok}]}), + perhaps_verbose_c110(P_latest2, S), + %% We very intentionally do *not* pass P_latest2 forward: we must avoid + %% bloating the dbg2 list! + react_to_env_C120(P_latest, [], S); + {{error, bad_arg}, _Goo} -> + ?REACT({c120, [{write, bad_arg}]}), + %% seems to work: react_to_env_A50(P_latest, [], S); % stop for now... + + %% React to new public write by restarting the iteration. + %% Hrmmm, going back to A20 triggers {error,written} problem?? + react_to_env_A20(0, S); Else -> Summ = machi_projection:make_summary(P_latest), - io:format(user, "C11 error by ~w: ~w, ~w, ~w\n", + io:format(user, "C110 error by ~w: ~w, ~w\n~p\n", [MyName, Else, Summ, get(react)]), - error_logger:error_msg("C11 error by ~w: ~w, ~w, ~w\n", + error_logger:error_msg("C110 error by ~w: ~w, ~w, ~w\n", [MyName, Else, Summ, get(react)]), exit({c110_failure, MyName, Else, Summ}) - end, - case proplists:get_value(private_write_verbose, S#ch_mgr.opts) of - true -> - {_,_,C} = os:timestamp(), - MSec = trunc(C / 1000), - {HH,MM,SS} = time(), - P_latest2x = P_latest2#projection_v1{dbg2=[]}, % limit verbose len. - case inner_projection_exists(P_latest2) of - false -> - Last2 = get(last_verbose), - Summ2 = machi_projection:make_summary(P_latest2x), - case proplists:get_value(private_write_verbose, - S#ch_mgr.opts) of - true when Summ2 /= Last2 -> - put(last_verbose, Summ2), - ?V("\n~2..0w:~2..0w:~2..0w.~3..0w ~p uses plain: ~w\n", - [HH,MM,SS,MSec, S#ch_mgr.name, Summ2]); - _ -> - ok - end; - true -> - Last2 = get(last_verbose), - P_inner = inner_projection_or_self(P_latest2), - P_innerx = P_inner#projection_v1{dbg2=[]}, % limit verbose len. - Summ2 = machi_projection:make_summary(P_innerx), - case proplists:get_value(private_write_verbose, - S#ch_mgr.opts) of - true when Summ2 /= Last2 -> - put(last_verbose, Summ2), - ?V("\n~2..0w:~2..0w:~2..0w.~3..0w ~p uses inner: ~w\n", - [HH,MM,SS,MSec, S#ch_mgr.name, Summ2]); - _ -> - ok - end - end; - _ -> - ok - end, - react_to_env_C120(P_latest, [], S). + end. react_to_env_C120(P_latest, FinalProps, #ch_mgr{proj_history=H, sane_transitions=Xtns}=S) -> @@ -2403,3 +2376,42 @@ all_hosed_history(#projection_v1{epoch_number=_Epoch, flap=Flap}, true -> {AllHosed, [AllHosed|Acc]} end. + +perhaps_verbose_c110(P_latest2, S) -> + case proplists:get_value(private_write_verbose, S#ch_mgr.opts) of + true -> + {_,_,C} = os:timestamp(), + MSec = trunc(C / 1000), + {HH,MM,SS} = time(), + P_latest2x = P_latest2#projection_v1{dbg2=[]}, % limit verbose len. + case inner_projection_exists(P_latest2) of + false -> + Last2 = get(last_verbose), + Summ2 = machi_projection:make_summary(P_latest2x), + case proplists:get_value(private_write_verbose, + S#ch_mgr.opts) of + true when Summ2 /= Last2 -> + put(last_verbose, Summ2), + ?V("\n~2..0w:~2..0w:~2..0w.~3..0w ~p uses plain: ~w\n", + [HH,MM,SS,MSec, S#ch_mgr.name, Summ2]); + _ -> + ok + end; + true -> + Last2 = get(last_verbose), + P_inner = inner_projection_or_self(P_latest2), + P_innerx = P_inner#projection_v1{dbg2=[]}, % limit verbose len. + Summ2 = machi_projection:make_summary(P_innerx), + case proplists:get_value(private_write_verbose, + S#ch_mgr.opts) of + true when Summ2 /= Last2 -> + put(last_verbose, Summ2), + ?V("\n~2..0w:~2..0w:~2..0w.~3..0w ~p uses inner: ~w\n", + [HH,MM,SS,MSec, S#ch_mgr.name, Summ2]); + _ -> + ok + end + end; + _ -> + ok + end.