Skip to content

Commit

Permalink
Merge pull request rabbitmq#10171 from cloudamqp/mgmt_db_cache_alread…
Browse files Browse the repository at this point in the history
…y_started

Tolerate race condition when starting management db cache process
  • Loading branch information
michaelklishin authored Dec 19, 2023
2 parents 5b9ed8b + f4a9edf commit 5eb4eef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions deps/rabbitmq_management/src/rabbit_mgmt_db_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ fetch(Key, FetchFun, FunArgs, Timeout) ->
ProcName = process_name(Key),
Pid = case whereis(ProcName) of
undefined ->
{ok, P} = supervisor:start_child(rabbit_mgmt_db_cache_sup,
?CHILD(Key)),
P;
case supervisor:start_child(rabbit_mgmt_db_cache_sup,
?CHILD(Key)) of
{ok, P} ->
P;
{error, {already_started, P}} ->
%% A parallel request started the cache meanwhile
P
end;
P -> P
end,
gen_server:call(Pid, {fetch, FetchFun, FunArgs}, Timeout).
Expand Down

0 comments on commit 5eb4eef

Please sign in to comment.