From a9b1c86956a85294debb3ff8c2704fdc4f83f906 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Wed, 4 Aug 2021 16:58:44 +0300 Subject: [PATCH] More mirrored supervisor logging (cherry picked from commit 9a0f4b17cdff7ec9efb5fc88ac92cc807ba4b2bd) --- .../rabbit_common/src/mirrored_supervisor.erl | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/deps/rabbit_common/src/mirrored_supervisor.erl b/deps/rabbit_common/src/mirrored_supervisor.erl index 6c691bd517b9..204a34e46386 100644 --- a/deps/rabbit_common/src/mirrored_supervisor.erl +++ b/deps/rabbit_common/src/mirrored_supervisor.erl @@ -278,12 +278,14 @@ handle_call({init, Overall}, _From, initial_childspecs = ChildSpecs}) -> process_flag(trap_exit, true), ok = pg:join(Group, Overall), - rabbit_log:debug("Mirrored supervisor: initializing, joined group ~p", [Group]), + rabbit_log:debug("Mirrored supervisor: initializing, overall supervisor ~p joined group ~p", [Overall, Group]), Rest = pg:get_members(Group) -- [Overall], Nodes = [node(M) || M <- Rest], rabbit_log:debug("Mirrored supervisor: known group ~p members: ~p on nodes ~p", [Group, Rest, Nodes]), case Rest of - [] -> TxFun(fun() -> delete_all(Group) end); + [] -> + rabbit_log:debug("Mirrored supervisor: no known peer members in group ~p, will delete all child records for it", [Group]), + TxFun(fun() -> delete_all(Group) end); _ -> ok end, [begin @@ -414,7 +416,8 @@ maybe_start(Group, TxFun, Overall, Delegate, ChildSpec) -> end. check_start(Group, Overall, Delegate, ChildSpec) -> - rabbit_log:debug("Mirrored supervisor: check_start for group ~p, id: ~p", [Group, id(ChildSpec)]), + rabbit_log:debug("Mirrored supervisor: check_start for group ~p, id: ~p, overall: ~p", + [Group, id(ChildSpec), Overall]), ReadResult = mnesia:wread({?TABLE, {Group, id(ChildSpec)}}), rabbit_log:debug("Mirrored supervisor: check_start table ~s read for key ~p returned ~p", [?TABLE, {Group, id(ChildSpec)}, ReadResult]), @@ -424,12 +427,19 @@ check_start(Group, Overall, Delegate, ChildSpec) -> [S] -> #mirrored_sup_childspec{key = {Group, Id}, mirroring_pid = Pid} = S, case Overall of - Pid -> child(Delegate, Id); - _ -> case supervisor(Pid) of - dead -> _ = write(Group, Overall, ChildSpec), - start; - Delegate0 -> child(Delegate0, Id) - end + Pid -> + rabbit_log:debug("Mirrored supervisor: overall matched mirrored pid ~p", [Pid]), + child(Delegate, Id); + _ -> + rabbit_log:debug("Mirrored supervisor: overall ~p did not match mirrored pid ~p", [Overall, Pid]), + rabbit_log:debug("Mirrored supervisor: supervisor(~p) returned ~p", [Pid, supervisor(Pid)]), + case supervisor(Pid) of + dead -> + _ = write(Group, Overall, ChildSpec), + start; + Delegate0 -> + child(Delegate0, Id) + end end end. @@ -460,6 +470,8 @@ stop(Group, TxFun, Delegate, Id) -> end. check_stop(Group, Delegate, Id) -> + rabbit_log:debug("Mirrored supervisor: checking if child ~p in group ~p should be stopped: ~p", + [Id, Group, child(Delegate, Id)]), case child(Delegate, Id) of undefined -> delete(Group, Id), deleted;