Skip to content

Commit 5cff713

Browse files
Merge pull request #1220 from rabbitmq/rabbitmq-server-1216
Revert "Use new supervisor2:prep_stop to stop rabbit dependencies on shutdown"
2 parents 2f4c27f + 6d52987 commit 5cff713

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/rabbit_sup.erl

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
-module(rabbit_sup).
1818

19-
-behaviour(supervisor2).
19+
-behaviour(supervisor).
2020

2121
-export([start_link/0, start_child/1, start_child/2, start_child/3, start_child/4,
2222
start_supervisor_child/1, start_supervisor_child/2,
@@ -25,7 +25,7 @@
2525
start_delayed_restartable_child/1, start_delayed_restartable_child/2,
2626
stop_child/1]).
2727

28-
-export([init/1, prep_stop/0]).
28+
-export([init/1]).
2929

3030
-include("rabbit.hrl").
3131

@@ -49,20 +49,20 @@
4949

5050
%%----------------------------------------------------------------------------
5151

52-
start_link() -> supervisor2:start_link({local, ?SERVER}, ?MODULE, []).
52+
start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []).
5353

5454
start_child(Mod) -> start_child(Mod, []).
5555

5656
start_child(Mod, Args) -> start_child(Mod, Mod, Args).
5757

5858
start_child(ChildId, Mod, Args) ->
59-
child_reply(supervisor2:start_child(
59+
child_reply(supervisor:start_child(
6060
?SERVER,
6161
{ChildId, {Mod, start_link, Args},
6262
transient, ?WORKER_WAIT, worker, [Mod]})).
6363

6464
start_child(ChildId, Mod, Fun, Args) ->
65-
child_reply(supervisor2:start_child(
65+
child_reply(supervisor:start_child(
6666
?SERVER,
6767
{ChildId, {Mod, Fun, Args},
6868
transient, ?WORKER_WAIT, worker, [Mod]})).
@@ -73,7 +73,7 @@ start_supervisor_child(Mod) -> start_supervisor_child(Mod, []).
7373
start_supervisor_child(Mod, Args) -> start_supervisor_child(Mod, Mod, Args).
7474

7575
start_supervisor_child(ChildId, Mod, Args) ->
76-
child_reply(supervisor2:start_child(
76+
child_reply(supervisor:start_child(
7777
?SERVER,
7878
{ChildId, {Mod, start_link, Args},
7979
transient, infinity, supervisor, [Mod]})).
@@ -85,25 +85,20 @@ start_delayed_restartable_child(M, A) -> start_restartable_child(M, A, true).
8585

8686
start_restartable_child(Mod, Args, Delay) ->
8787
Name = list_to_atom(atom_to_list(Mod) ++ "_sup"),
88-
child_reply(supervisor2:start_child(
88+
child_reply(supervisor:start_child(
8989
?SERVER,
9090
{Name, {rabbit_restartable_sup, start_link,
9191
[Name, {Mod, start_link, Args}, Delay]},
9292
transient, infinity, supervisor, [rabbit_restartable_sup]})).
9393

9494
stop_child(ChildId) ->
95-
case supervisor2:terminate_child(?SERVER, ChildId) of
96-
ok -> supervisor2:delete_child(?SERVER, ChildId);
95+
case supervisor:terminate_child(?SERVER, ChildId) of
96+
ok -> supervisor:delete_child(?SERVER, ChildId);
9797
E -> E
9898
end.
9999

100100
init([]) -> {ok, {{one_for_all, 0, 1}, []}}.
101101

102-
prep_stop() ->
103-
rabbit_log:info("Stopping dependencies...~n",[]),
104-
Apps = rabbit_plugins:active(),
105-
rabbit:stop_apps(app_utils:app_dependency_order(Apps, true)),
106-
rabbit_log:info("Dependencies stopped...~n",[]).
107102

108103
%%----------------------------------------------------------------------------
109104

test/clustering_management_SUITE.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ join_cluster_bad_operations(Config) ->
183183
ok = stop_app(Hare),
184184
assert_failure(fun () -> start_app(Hare) end),
185185
ok = start_app(Rabbit),
186-
ok = start_app(Hare),
186+
%% The Erlang VM has stopped after previous rabbit app failure
187+
ok = rabbit_ct_broker_helpers:start_node(Config, Hare),
187188
ok.
188189

189190
%% This tests that the nodes in the cluster are notified immediately of a node
@@ -535,25 +536,34 @@ erlang_config(Config) ->
535536
ok = reset(Hare),
536537
ok = rpc:call(Hare, application, set_env,
537538
[rabbit, cluster_nodes, {["Mike's computer"], disc}]),
539+
%% Rabbit app stops abnormally, node goes down
538540
assert_failure(fun () -> start_app(Hare) end),
539541
assert_not_clustered(Rabbit),
540542

541543
%% If we use an invalid node type, the node fails to start.
544+
%% The Erlang VM has stopped after previous rabbit app failure
545+
ok = rabbit_ct_broker_helpers:start_node(Config, Hare),
542546
ok = stop_app(Hare),
543547
ok = reset(Hare),
544548
ok = rpc:call(Hare, application, set_env,
545549
[rabbit, cluster_nodes, {[Rabbit], blue}]),
550+
%% Rabbit app stops abnormally, node goes down
546551
assert_failure(fun () -> start_app(Hare) end),
547552
assert_not_clustered(Rabbit),
548553

549554
%% If we use an invalid cluster_nodes conf, the node fails to start.
555+
%% The Erlang VM has stopped after previous rabbit app failure
556+
ok = rabbit_ct_broker_helpers:start_node(Config, Hare),
550557
ok = stop_app(Hare),
551558
ok = reset(Hare),
552559
ok = rpc:call(Hare, application, set_env,
553560
[rabbit, cluster_nodes, true]),
561+
%% Rabbit app stops abnormally, node goes down
554562
assert_failure(fun () -> start_app(Hare) end),
555563
assert_not_clustered(Rabbit),
556564

565+
%% The Erlang VM has stopped after previous rabbit app failure
566+
ok = rabbit_ct_broker_helpers:start_node(Config, Hare),
557567
ok = stop_app(Hare),
558568
ok = reset(Hare),
559569
ok = rpc:call(Hare, application, set_env,

0 commit comments

Comments
 (0)