From b268f36b8f10186b9ac9e24d556e854183bcd328 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Thu, 2 Feb 2023 00:23:19 +0100 Subject: [PATCH] fix: Fix flaky t_core_node_down testcase Fixes: #113 --- src/mria_shards_sup.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mria_shards_sup.erl b/src/mria_shards_sup.erl index 5b80f11..ba7093d 100644 --- a/src/mria_shards_sup.erl +++ b/src/mria_shards_sup.erl @@ -42,8 +42,15 @@ find_shard(Shard) -> -spec start_shard(mria_rlog:shard()) -> {ok, pid()} | {error, _}. start_shard(Shard) -> - Child = shard_sup(Shard), - supervisor:start_child(?SUPERVISOR, Child). + case whereis(?SUPERVISOR) of + undefined -> + %% FIXME: communicate via CVAR instead + timer:sleep(100), + start_shard(Shard); + _Pid -> + Child = shard_sup(Shard), + supervisor:start_child(?SUPERVISOR, Child) + end. %% @doc Restart a shard -spec restart_shard(mria_rlog:shard(), _Reason) -> ok.