Skip to content

Commit ab31db1

Browse files
Merge pull request #10178 from rabbitmq/mergify/bp/v3.12.x/pr-10171
Tolerate race condition when starting management db cache process (backport #10171)
2 parents 38a79db + 6638fef commit ab31db1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

deps/rabbitmq_management/src/rabbit_mgmt_db_cache.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ fetch(Key, FetchFun, FunArgs, Timeout) ->
6565
ProcName = process_name(Key),
6666
Pid = case whereis(ProcName) of
6767
undefined ->
68-
{ok, P} = supervisor:start_child(rabbit_mgmt_db_cache_sup,
69-
?CHILD(Key)),
70-
P;
68+
case supervisor:start_child(rabbit_mgmt_db_cache_sup,
69+
?CHILD(Key)) of
70+
{ok, P} ->
71+
P;
72+
{error, {already_started, P}} ->
73+
%% A parallel request started the cache meanwhile
74+
P
75+
end;
7176
P -> P
7277
end,
7378
gen_server:call(Pid, {fetch, FetchFun, FunArgs}, Timeout).

0 commit comments

Comments
 (0)