Skip to content

Commit 891ba1a

Browse files
committed
rabbit_deprecated_features: Improve reliability of the classic_queue_mirroring callback
[Why] The callback wants to query the `rabbit_runtime_parameters` Mnesia table to see if there HA policies configured. However this table may exist but may be unavailable. This is the case in a cluster if the node running the callback has to wait for another cluster member before Mnesia tables can be queried or updated. [How] Once we verified the `rabbit_runtime_parameters` Mnesia table exists, we wait for its availability before we query it. `rabbit_table:wait/2` will throw an exception if the wait times out. In particular this avoids an infinite loop in `mnesia_to_khepri:handle_fallback()` because it relies on the availability of the table too to determine if the table is being migrated or not.
1 parent c13397b commit 891ba1a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

deps/rabbit/src/rabbit_mirror_queue_misc.erl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,16 @@ are_cmqs_used(_) ->
962962
RuntimeParamsReady = lists:member(
963963
rabbit_runtime_parameters, AllTables),
964964
case RuntimeParamsReady of
965-
true -> are_cmqs_used1();
966-
false -> false
965+
true ->
966+
%% We also wait for the table because it could exist but
967+
%% may be unavailable. For instance, Mnesia needs another
968+
%% replica on another node before it considers it to be
969+
%% available.
970+
rabbit_table:wait(
971+
[rabbit_runtime_parameters], _Retry = true),
972+
are_cmqs_used1();
973+
false ->
974+
false
967975
end
968976
end.
969977

0 commit comments

Comments
 (0)