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

View file

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

View file

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

View file

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