Skip to content

Commit 9a0f4b1

Browse files
More mirrored supervisor logging
1 parent 4f3d5e5 commit 9a0f4b1

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

deps/rabbit_common/src/mirrored_supervisor.erl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,14 @@ handle_call({init, Overall}, _From,
278278
initial_childspecs = ChildSpecs}) ->
279279
process_flag(trap_exit, true),
280280
ok = pg:join(Group, Overall),
281-
rabbit_log:debug("Mirrored supervisor: initializing, joined group ~p", [Group]),
281+
rabbit_log:debug("Mirrored supervisor: initializing, overall supervisor ~p joined group ~p", [Overall, Group]),
282282
Rest = pg:get_members(Group) -- [Overall],
283283
Nodes = [node(M) || M <- Rest],
284284
rabbit_log:debug("Mirrored supervisor: known group ~p members: ~p on nodes ~p", [Group, Rest, Nodes]),
285285
case Rest of
286-
[] -> TxFun(fun() -> delete_all(Group) end);
286+
[] ->
287+
rabbit_log:debug("Mirrored supervisor: no known peer members in group ~p, will delete all child records for it", [Group]),
288+
TxFun(fun() -> delete_all(Group) end);
287289
_ -> ok
288290
end,
289291
[begin
@@ -414,7 +416,8 @@ maybe_start(Group, TxFun, Overall, Delegate, ChildSpec) ->
414416
end.
415417

416418
check_start(Group, Overall, Delegate, ChildSpec) ->
417-
rabbit_log:debug("Mirrored supervisor: check_start for group ~p, id: ~p", [Group, id(ChildSpec)]),
419+
rabbit_log:debug("Mirrored supervisor: check_start for group ~p, id: ~p, overall: ~p",
420+
[Group, id(ChildSpec), Overall]),
418421
ReadResult = mnesia:wread({?TABLE, {Group, id(ChildSpec)}}),
419422
rabbit_log:debug("Mirrored supervisor: check_start table ~s read for key ~p returned ~p",
420423
[?TABLE, {Group, id(ChildSpec)}, ReadResult]),
@@ -424,12 +427,19 @@ check_start(Group, Overall, Delegate, ChildSpec) ->
424427
[S] -> #mirrored_sup_childspec{key = {Group, Id},
425428
mirroring_pid = Pid} = S,
426429
case Overall of
427-
Pid -> child(Delegate, Id);
428-
_ -> case supervisor(Pid) of
429-
dead -> _ = write(Group, Overall, ChildSpec),
430-
start;
431-
Delegate0 -> child(Delegate0, Id)
432-
end
430+
Pid ->
431+
rabbit_log:debug("Mirrored supervisor: overall matched mirrored pid ~p", [Pid]),
432+
child(Delegate, Id);
433+
_ ->
434+
rabbit_log:debug("Mirrored supervisor: overall ~p did not match mirrored pid ~p", [Overall, Pid]),
435+
rabbit_log:debug("Mirrored supervisor: supervisor(~p) returned ~p", [Pid, supervisor(Pid)]),
436+
case supervisor(Pid) of
437+
dead ->
438+
_ = write(Group, Overall, ChildSpec),
439+
start;
440+
Delegate0 ->
441+
child(Delegate0, Id)
442+
end
433443
end
434444
end.
435445

@@ -460,6 +470,8 @@ stop(Group, TxFun, Delegate, Id) ->
460470
end.
461471

462472
check_stop(Group, Delegate, Id) ->
473+
rabbit_log:debug("Mirrored supervisor: checking if child ~p in group ~p should be stopped: ~p",
474+
[Id, Group, child(Delegate, Id)]),
463475
case child(Delegate, Id) of
464476
undefined -> delete(Group, Id),
465477
deleted;

0 commit comments

Comments
 (0)