Skip to content

Commit be44ef2

Browse files
authored
Merge pull request #524 from rabbitmq/misc-fixes
Register with ra directory before initialising ra server.
2 parents ee45d3d + a231a64 commit be44ef2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/ra_server_proc.erl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ init(Config) ->
311311
{ok, recover, State, [{next_event, cast, go}]}.
312312

313313
do_init(#{id := Id,
314+
uid := UId,
314315
cluster_name := ClusterName} = Config0) ->
315316
Key = ra_lib:ra_server_id_to_local_name(Id),
316317
true = ets:insert(ra_state, {Key, init, unknown}),
@@ -325,15 +326,12 @@ do_init(#{id := Id,
325326
process_flag(message_queue_data, MsgQData),
326327
process_flag(min_bin_vheap_size, MinBinVheapSize),
327328
process_flag(min_heap_size, MinHeapSize),
328-
%% wait for wal for a bit before initialising the server state and log
329-
#{cluster := Cluster} = ServerState = ra_server:init(Config),
330-
LogId = ra_server:log_id(ServerState),
331-
UId = ra_server:uid(ServerState),
332-
% ensure ra_directory has the new pid
333329
#{names := Names} = SysConf,
330+
%% register with ra_directory _before_ initialsing the ra server state
334331
ok = ra_directory:register_name(Names, UId, self(),
335332
maps:get(parent, Config, undefined), Key,
336333
ClusterName),
334+
#{cluster := Cluster} = ServerState = ra_server:init(Config),
337335

338336
% ensure each relevant erlang node is connected
339337
PeerNodes = [PeerNode ||
@@ -362,6 +360,7 @@ do_init(#{id := Id,
362360
ReceiveSnapshotTimeout = maps:get(receive_snapshot_timeout, SysConf,
363361
?DEFAULT_RECEIVE_SNAPSHOT_TIMEOUT),
364362
AtenPollInt = application:get_env(aten, poll_interval, 1000),
363+
LogId = ra_server:log_id(ServerState),
365364
State = #state{conf = #conf{log_id = LogId,
366365
cluster_name = ClusterName,
367366
name = Key,

0 commit comments

Comments
 (0)