25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Fix race condition in Redis/SQL supervisors startup

This commit is contained in:
Evgeny Khramtsov 2019-10-29 13:36:40 +03:00
parent 86c4f76c51
commit 72f6835feb
2 changed files with 8 additions and 2 deletions

View File

@ -45,7 +45,10 @@ start() ->
permanent, infinity, supervisor, [?MODULE]}, permanent, infinity, supervisor, [?MODULE]},
case supervisor:start_child(ejabberd_db_sup, Spec) of case supervisor:start_child(ejabberd_db_sup, Spec) of
{ok, _} -> ok; {ok, _} -> ok;
{error, {already_started, _}} -> ok; {error, {already_started, Pid}} ->
%% Wait for the supervisor to fully start
_ = supervisor:count_children(Pid),
ok;
{error, Why} = Err -> {error, Why} = Err ->
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]), ?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
Err Err

View File

@ -52,7 +52,10 @@ start(Host) ->
modules => [?MODULE]}, modules => [?MODULE]},
case supervisor:start_child(ejabberd_db_sup, Spec) of case supervisor:start_child(ejabberd_db_sup, Spec) of
{ok, _} -> ok; {ok, _} -> ok;
{error, {already_started, _}} -> ok; {error, {already_started, Pid}} ->
%% Wait for the supervisor to fully start
_ = supervisor:count_children(Pid),
ok;
{error, Why} = Err -> {error, Why} = Err ->
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]), ?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
Err Err