Skip to content

Commit

Permalink
Merge pull request #2417 from rabbitmq/mark-node-as-ready-after-it-is
Browse files Browse the repository at this point in the history
Mark node as ready after it actually is

(cherry picked from commit 2b54235)

 Conflicts:
	.github/workflows/test-erlang-otp-23.0.yaml
	.github/workflows/test-jobs/30-CT_SUITE.yaml
	src/rabbit.erl
  • Loading branch information
dumbbell authored and michaelklishin committed Jul 27, 2020
1 parent 3011080 commit 63253f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
30 changes: 17 additions & 13 deletions src/rabbit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ status() ->
{log_files, log_locations()},
{data_directory, rabbit_mnesia:dir()},
{raft_data_directory, ra_env:data_dir()}],
Totals = case rabbit:is_running() of
Totals = case is_running() of
true ->
[{virtual_host_count, rabbit_vhost:count()},
{connection_count,
Expand Down Expand Up @@ -911,23 +911,27 @@ do_run_postlaunch_phase() ->
end
end, Plugins),

rabbit_log_prelaunch:debug("Marking ~s as running", [product_name()]),
rabbit_boot_state:set(ready),

ok = rabbit_lager:broker_is_started(),
ok = log_broker_started(
rabbit_plugins:strictly_plugins(rabbit_plugins:active())),
%% export definitions after all plugins have been enabled,
%% Export definitions after all plugins have been enabled,
%% see rabbitmq/rabbitmq-server#2384
case rabbit_definitions:maybe_load_definitions() of
ok -> ok;
ok -> ok;
DefLoadError -> throw(DefLoadError)
end,

%% start listeners after all plugins have been enabled,
%% see rabbitmq/rabbitmq-server#2405
rabbit_log_prelaunch:info("Ready to start client connection listeners"),
ok = rabbit_networking:boot()
%% Start listeners after all plugins have been enabled,
%% see rabbitmq/rabbitmq-server#2405.
rabbit_log_prelaunch:info(
"Ready to start client connection listeners"),
ok = rabbit_networking:boot(),

%% The node is ready: mark it as such and log it.
%% NOTE: PLEASE DO NOT ADD CRITICAL NODE STARTUP CODE AFTER THIS.
ok = rabbit_lager:broker_is_started(),
ok = log_broker_started(
rabbit_plugins:strictly_plugins(rabbit_plugins:active())),

rabbit_log_prelaunch:debug("Marking ~s as running", [product_name()]),
rabbit_boot_state:set(ready)
catch
throw:{error, _} = Error ->
rabbit_prelaunch_errors:log_error(Error),
Expand Down
17 changes: 9 additions & 8 deletions src/rabbit_networking.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@
-type protocol() :: atom().
-type label() :: string().

%% @todo Remove once Dialyzer only runs on Erlang/OTP 21.3 or above.
-dialyzer({nowarn_function, boot/0}).
-dialyzer({nowarn_function, boot_listeners/3}).
-dialyzer({nowarn_function, record_distribution_listener/0}).

-spec boot() -> 'ok'.
-spec boot() -> 'ok' | no_return().

boot() ->
ok = record_distribution_listener(),
Expand Down Expand Up @@ -282,10 +277,16 @@ tcp_listener_stopped(Protocol, Opts, IPAddress, Port) ->
port = Port,
opts = Opts}).

-spec record_distribution_listener() -> ok | no_return().

record_distribution_listener() ->
{Name, Host} = rabbit_nodes:parts(node()),
{port, Port, _Version} = erl_epmd:port_please(Name, Host),
tcp_listener_started(clustering, [], {0,0,0,0,0,0,0,0}, Port).
case erl_epmd:port_please(Name, Host, infinity) of
{port, Port, _Version} ->
tcp_listener_started(clustering, [], {0,0,0,0,0,0,0,0}, Port);
noport ->
throw({error, no_epmd_port})
end.

-spec active_listeners() -> [rabbit_types:listener()].

Expand Down

0 comments on commit 63253f0

Please sign in to comment.