Skip to content

Commit 1594661

Browse files
committed
mirrored_sup
1 parent fb660f2 commit 1594661

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

deps/rabbit/src/mirrored_supervisor.erl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,7 @@ handle_info({'DOWN', _Ref, process, Pid, _Reason},
345345
child_order = ChildOrder}) ->
346346
%% No guarantee pg will have received the DOWN before us.
347347
R = case lists:sort(pg:get_members(Group)) -- [Pid] of
348-
[O | _] -> ChildSpecs = case update_all(O, Pid) of
349-
List when is_list(List) -> List;
350-
{error, timeout} -> []
351-
end,
348+
[O | _] -> ChildSpecs = retry_update_all(O, Pid),
352349
[start(Delegate, ChildSpec)
353350
|| ChildSpec <- restore_child_order(ChildSpecs,
354351
ChildOrder)];
@@ -359,6 +356,22 @@ handle_info({'DOWN', _Ref, process, Pid, _Reason},
359356
Errors -> {stop, {shutdown, Errors}, State}
360357
end;
361358

359+
retry_update_all(O, Pid) ->
360+
retry_update_all(O, Pid, 10000).
361+
362+
retry_update_all(O, Pid, TimeLeft) when TimeLeft > 0 ->
363+
case update_all(O, Pid) of
364+
List when is_list(List) ->
365+
List;
366+
{error, timeout} ->
367+
Sleep = 200,
368+
TimeLeft1 = TimeLeft - Sleep,
369+
timer:sleep(Sleep),
370+
retry_update_all(O, Pid, TimeLeft1)
371+
end;
372+
retry_update_all(O, Pid, _TimeLeft) ->
373+
update_all(O, Pid).
374+
362375
handle_info(Info, State) ->
363376
{stop, {unexpected_info, Info}, State}.
364377

0 commit comments

Comments
 (0)