summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2018-03-16 16:37:30 +0300
committerGitHub <noreply@github.com>2018-03-16 16:37:30 +0300
commit2ae6ba6578baaef95657d1b90470f848d464eeb7 (patch)
treef36b209186ea0bf66c1bbc45fa02b0c875d3265e /src
parente431a622cd1b018aa2f1eb83d6dba18fbd53b365 (diff)
parentfc8abae47427eb9ae4347177cc23dd9d4e10ba35 (diff)
downloadrabbitmq-server-git-2ae6ba6578baaef95657d1b90470f848d464eeb7.tar.gz
Merge pull request #1556 from rabbitmq/vhost-sup-race
Do not try to start a vhost supervisors on not fully booted nodes.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit.erl8
-rw-r--r--src/rabbit_vhost_sup_sup.erl10
2 files changed, 14 insertions, 4 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 37b33bd8a4..cde1d0ad07 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -27,6 +27,7 @@
-export([start/2, stop/1, prep_stop/1]).
-export([start_apps/1, start_apps/2, stop_apps/1]).
-export([log_locations/0, config_files/0, decrypt_config/2]). %% for testing and mgmt-agent
+-export([is_booted/1]).
-ifdef(TEST).
@@ -745,6 +746,13 @@ is_running() -> is_running(node()).
is_running(Node) -> rabbit_nodes:is_process_running(Node, rabbit).
+is_booted(Node) ->
+ case is_booting(Node) of
+ false ->
+ is_running(Node);
+ _ -> false
+ end.
+
environment() ->
%% The timeout value is twice that of gen_server:call/2.
[{A, environment(A)} ||
diff --git a/src/rabbit_vhost_sup_sup.erl b/src/rabbit_vhost_sup_sup.erl
index 558648400a..3ce3201d6b 100644
--- a/src/rabbit_vhost_sup_sup.erl
+++ b/src/rabbit_vhost_sup_sup.erl
@@ -60,14 +60,16 @@ init([]) ->
[rabbit_vhost_sup_wrapper, rabbit_vhost_sup]}]}}.
start_on_all_nodes(VHost) ->
- NodesStart = [ {Node, start_vhost(VHost, Node)}
- || Node <- rabbit_nodes:all_running() ],
- Failures = lists:filter(fun
+ %% Do not try to start a vhost on booting peer nodes
+ AllBooted = [Node || Node <- rabbit_nodes:all_running(), rabbit:is_booted(Node)],
+ Nodes = [node() | AllBooted],
+ Results = [{Node, start_vhost(VHost, Node)} || Node <- Nodes],
+ Failures = lists:filter(fun
({_, {ok, _}}) -> false;
({_, {error, {already_started, _}}}) -> false;
(_) -> true
end,
- NodesStart),
+ Results),
case Failures of
[] -> ok;
Errors -> {error, {failed_to_start_vhost_on_nodes, Errors}}