Skip to content

Commit

Permalink
Warn when lock could not be acquired successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Aug 5, 2021
1 parent 22add3c commit c84115f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deps/rabbit_common/src/mirrored_supervisor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ handle_call({init, Overall}, _From,
initial_childspecs = ChildSpecs}) ->
process_flag(trap_exit, true),
LockId = mirrored_supervisor_locks:lock(Group),
maybe_log_lock_acquisition_failure(LockId, Group),
ok = pg:join(Group, Overall),
rabbit_log:debug("Mirrored supervisor: initializing, overall supervisor ~p joined group ~p", [Overall, Group]),
Rest = pg:get_members(Group) -- [Overall],
Expand Down Expand Up @@ -309,6 +310,7 @@ handle_call({start_child, ChildSpec}, _From,
group = Group,
tx_fun = TxFun}) ->
LockId = mirrored_supervisor_locks:lock(Group),
maybe_log_lock_acquisition_failure(LockId, Group),
rabbit_log:debug("Mirrored supervisor: asked to consider starting a child, group: ~p", [Group]),
Result = case maybe_start(Group, TxFun, Overall, Delegate, ChildSpec) of
already_in_mnesia ->
Expand Down Expand Up @@ -549,3 +551,8 @@ restore_child_order(ChildSpecs, ChildOrder) ->
proplists:get_value(id(A), ChildOrder)
< proplists:get_value(id(B), ChildOrder)
end, ChildSpecs).

maybe_log_lock_acquisition_failure(undefined = _LockId, Group) ->
rabbit_log:warning("Mirrored supervisor: could not acquire lock for group ~s", [Group]);
maybe_log_lock_acquisition_failure(_, _) ->
ok.

0 comments on commit c84115f

Please sign in to comment.