Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion deps/rabbit/src/rabbit_khepri.erl
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ setup(_) ->
case khepri:start(?RA_SYSTEM, RaServerConfig) of
{ok, ?STORE_ID} ->
wait_for_leader(),
register_projections(),
wait_for_register_projections(),
?LOG_DEBUG(
"Khepri-based " ?RA_FRIENDLY_NAME " ready",
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
Expand Down Expand Up @@ -306,6 +306,21 @@ wait_for_leader(Timeout, Retries) ->
throw(Reason)
end.

wait_for_register_projections() ->
wait_for_register_projections(retry_timeout(), retry_limit()).

wait_for_register_projections(_Timeout, 0) ->
exit(timeout_waiting_for_khepri_projections);
wait_for_register_projections(Timeout, Retries) ->
rabbit_log:info("Waiting for Khepri projections for ~tp ms, ~tp retries left",
[Timeout, Retries - 1]),
try
register_projections()
catch
throw : timeout ->
wait_for_register_projections(Timeout, Retries -1)
end.

%% @private

can_join_cluster(DiscoveryNode) when is_atom(DiscoveryNode) ->
Expand Down
4 changes: 4 additions & 0 deletions deps/rabbitmq_cli/lib/rabbitmq/cli/default_output.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ defmodule RabbitMQ.CLI.DefaultOutput do
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(), khepri_timeout_error(node_name)}
end

defp format_khepri_output({:error, :timeout_waiting_for_khepri_projections}, %{node: node_name}) do
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(), khepri_timeout_error(node_name)}
end

defp format_khepri_output(result, _opts) do
result
end
Expand Down