summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-07-24 11:21:53 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-07-24 14:36:02 +0200
commit342c36370ddb08a047e4f6221447f684e6e1ba6e (patch)
treefb0ccf676a4ad61dd29dfa112c2a36459d49e6ed
parent8629a1cd3d59bfff96129e2cbc9b0d7042651675 (diff)
downloadrabbitmq-server-git-342c36370ddb08a047e4f6221447f684e6e1ba6e.tar.gz
rabbit: Move critical code back to before we mark the node as ready
`rabbit_networking:boot()` and the maintenance mode preparation was moved or added after we marked the node as ready. Therefore, functions such as `rabbit:is_running()` were lying. This led to bugs such as "rabbitmqctl wait" tu return too early, or testcases starting to run before the node was started and thus failing.
-rw-r--r--src/rabbit.erl33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 8298dfe79d..f58ae1db94 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -684,7 +684,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,
@@ -912,26 +912,31 @@ do_run_postlaunch_phase() ->
end
end, Plugins),
+ %% Successful boot resets node maintenance state.
rabbit_log_prelaunch:info("Resetting node maintenance status"),
- %% successful boot resets node maintenance state
- rabbit_maintenance:unmark_as_being_drained(),
- rabbit_log_prelaunch:debug("Marking ~s as running", [product_name()]),
- rabbit_boot_state:set(ready),
+ _ = rabbit_maintenance:unmark_as_being_drained(),
- 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),