Skip to content

Commit b1783bb

Browse files
authored
Merge pull request #336 from rabbitmq/handle-trigger_election-exception
khepri_cluster: Log an error if `trigger_election/2` fails during start
2 parents 564d584 + 1568a0e commit b1783bb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/khepri_cluster.erl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,17 @@ ensure_server_started_locked(
390390
[StoreId, RaSystem]),
391391
case do_start_server(RaSystem, RaServerConfig1) of
392392
ok ->
393-
ok = trigger_election(RaServerConfig1, Timeout),
394-
{ok, StoreId};
393+
try
394+
trigger_election(RaServerConfig1, Timeout),
395+
{ok, StoreId}
396+
catch
397+
Class:Reason:Stacktrace ->
398+
?LOG_ERROR(
399+
"Failed to trigger election on the freshly "
400+
"started Ra server for store \"~s\"::~n~p",
401+
[StoreId, Reason]),
402+
erlang:raise(Class, Reason, Stacktrace)
403+
end;
395404
Error ->
396405
Error
397406
end;
@@ -858,7 +867,7 @@ do_join_locked(StoreId, ThisMember, RemoteNode, Timeout) ->
858867
%% standalone (after a reset) and needs an election to be in a
859868
%% working state again. We don't care about the result at this
860869
%% point.
861-
_ = trigger_election(ThisMember, Timeout1),
870+
trigger_election(ThisMember, Timeout1),
862871
case Error of
863872
{timeout, _} -> {error, timeout};
864873
{error, _} -> Error

0 commit comments

Comments
 (0)