Skip to content

Commit ccf03c7

Browse files
dcorbachomergify[bot]
authored andcommitted
rabbit_khepri: Retry register_projections during boot
Gives some time to form a majority during the boot process, allowing nodes to boot more easily (cherry picked from commit f257e11)
1 parent be406d8 commit ccf03c7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ setup(_) ->
263263
case khepri:start(?RA_SYSTEM, RaServerConfig) of
264264
{ok, ?STORE_ID} ->
265265
wait_for_leader(),
266-
register_projections(),
266+
wait_for_register_projections(),
267267
?LOG_DEBUG(
268268
"Khepri-based " ?RA_FRIENDLY_NAME " ready",
269269
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
@@ -306,6 +306,21 @@ wait_for_leader(Timeout, Retries) ->
306306
throw(Reason)
307307
end.
308308

309+
wait_for_register_projections() ->
310+
wait_for_register_projections(retry_timeout(), retry_limit()).
311+
312+
wait_for_register_projections(_Timeout, 0) ->
313+
exit(timeout_waiting_for_khepri_projections);
314+
wait_for_register_projections(Timeout, Retries) ->
315+
rabbit_log:info("Waiting for Khepri projections for ~tp ms, ~tp retries left",
316+
[Timeout, Retries - 1]),
317+
try
318+
register_projections()
319+
catch
320+
throw : {timeout, _ServerId} ->
321+
wait_for_register_projections(Timeout, Retries -1)
322+
end.
323+
309324
%% @private
310325

311326
can_join_cluster(DiscoveryNode) when is_atom(DiscoveryNode) ->

0 commit comments

Comments
 (0)