Hooray??! Fix the damn PULSE hangs by using infinity supervisor shutdown times

This commit is contained in:
Scott Lystig Fritchie 2015-07-16 21:17:46 +09:00
parent dbbb6e8b14
commit c10200138c
4 changed files with 33 additions and 15 deletions

View file

@ -66,6 +66,9 @@
-ifdef(PULSE).
-compile({parse_transform, pulse_instrument}).
-include_lib("pulse_otp/include/pulse_otp.hrl").
-define(SHUTDOWN, infinity).
-else.
-define(SHUTDOWN, 5000).
-endif.
%% External API
@ -80,7 +83,7 @@
make_package_spec(FluName, TcpPort, DataDir, Props) ->
{FluName, {machi_flu_psup, start_link,
[FluName, TcpPort, DataDir, Props]},
permanent, 5000, supervisor, []}.
permanent, ?SHUTDOWN, supervisor, []}.
start_flu_package(FluName, TcpPort, DataDir, Props) ->
Spec = make_package_spec(FluName, TcpPort, DataDir, Props),
@ -111,15 +114,15 @@ init([FluName, TcpPort, DataDir, Props0]) ->
ProjSpec = {ProjRegName,
{machi_projection_store, start_link,
[ProjRegName, DataDir, FluName]},
permanent, 5000, worker, []},
permanent, ?SHUTDOWN, worker, []},
MgrSpec = {make_mgr_supname(FluName),
{machi_chain_manager1, start_link,
[FluName, [], Props]},
permanent, 5000, worker, []},
permanent, ?SHUTDOWN, worker, []},
FluSpec = {FluName,
{machi_flu1, start_link,
[ [{FluName, TcpPort, DataDir}|Props] ]},
permanent, 5000, worker, []},
permanent, ?SHUTDOWN, worker, []},
{ok, {SupFlags, [ProjSpec, MgrSpec, FluSpec]}}.
make_p_regname(FluName) when is_atom(FluName) ->

View file

@ -33,6 +33,9 @@
-ifdef(PULSE).
-compile({parse_transform, pulse_instrument}).
-include_lib("pulse_otp/include/pulse_otp.hrl").
-define(SHUTDOWN, infinity).
-else.
-define(SHUTDOWN, 5000).
-endif.
%% API

View file

@ -30,6 +30,9 @@
-ifdef(PULSE).
-compile({parse_transform, pulse_instrument}).
-include_lib("pulse_otp/include/pulse_otp.hrl").
-define(SHUTDOWN, infinity).
-else.
-define(SHUTDOWN, 5000).
-endif.
%% API
@ -44,7 +47,11 @@ start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
init([]) ->
erlang:display({flu_sup,self()}),
erlang:display({flu_sup,?LINE,self()}),
{_, Ps} = process_info(self(), links),
erlang:display({flu_sup,self(), links, Ps}),
[unlink(P) || P <- Ps],
erlang:display({flu_sup,?LINE,self()}),
RestartStrategy = one_for_one,
MaxRestarts = 1000,
MaxSecondsBetweenRestarts = 3600,
@ -52,7 +59,7 @@ init([]) ->
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
Restart = permanent,
Shutdown = 5000,
Shutdown = ?SHUTDOWN,
Type = supervisor,
ServerSup =

View file

@ -307,14 +307,17 @@ dump_state() ->
[P || P <- Ps,
P#projection_v1.epoch_number /= 0]
end} || {Name, Proxy} <- ProxiesDict],
?V("~w,", [ [{X,whereis(X)} || X <- [machi_sup, machi_flu_sup, machi_partition_simulator]] ]),
?V("~w,", [catch application:stop(machi)]),
[?V("~w,", [timer:sleep(10)]) || _ <- lists:seq(1,50)],
?V("~w,", [ [{X,whereis(X)} || X <- [machi_sup, machi_flu_sup, machi_partition_simulator]] ]),
?V(")", []),
Diag1 = Diag2 = "skip_diags",
{Report, PrivProjs, lists:flatten([Diag1, Diag2])}
catch XX:YY ->
?V("OUCH: ~p ~p @ ~p\n", [XX, YY, erlang:get_stacktrace()]),
?V("Exiting now to move to manual post-mortem....\n", []),
erlang:halt(0),
erlang:halt(66),
false
end.
@ -489,14 +492,16 @@ erlang:display({hard,?MODULE,?LINE,self()}),
(catch unlink(whereis(machi_partition_simulator))),
[begin
erlang:display({hard,?MODULE,?LINE,self(),X}),
Pid = whereis(X),
%%%%%%DELME deadlock source? spawn(fun() -> ?QC_FMT("shutdown-~w,", [self()]), (catch X:stop()) end),
timer:sleep(50),
timer:sleep(10),
(catch exit(Pid, shutdown)),
timer:sleep(1),
(catch exit(Pid, kill))
erlang:display({hard,?MODULE,?LINE,self(),X,Pid}),
okokokokokokwhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
%% %%%%%%DELME deadlock source? spawn(fun() -> ?QC_FMT("shutdown-~w,", [self()]), (catch X:stop()) end),
%% timer:sleep(50),
%% timer:sleep(10),
%% (catch exit(Pid, shutdown)),
%% timer:sleep(1),
%% (catch exit(Pid, kill))
%% end || X <- [machi_partition_simulator] ],
end || X <- [machi_partition_simulator, machi_flu_sup, machi_sup] ],
timer:sleep(100),
ok.