Skip to content

Commit 854160b

Browse files
committed
nodeup
1 parent 03a2a07 commit 854160b

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,8 +1944,16 @@ is_dead_exclusive(Q) when ?amqqueue_exclusive_owner_is_pid(Q) ->
19441944

19451945
-spec on_node_up(node()) -> 'ok'.
19461946

1947-
on_node_up(_Node) ->
1948-
ok.
1947+
on_node_up(Node) ->
1948+
case rabbit_khepri:is_enabled() of
1949+
true ->
1950+
%% With Khepri, we try to delete transient queues now because it's
1951+
%% possible any updates timed out because of the lack of a quorum
1952+
%% while `Node' was down.
1953+
ok = delete_transient_queues_on_node(Node);
1954+
false ->
1955+
ok
1956+
end.
19491957

19501958
-spec on_node_down(node()) -> 'ok'.
19511959

deps/rabbit/src/rabbit_node_monitor.erl

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,16 +430,8 @@ handle_call(status, _From, State = #state{partitions = Partitions}) ->
430430
handle_call(_Request, _From, State) ->
431431
{noreply, State}.
432432

433-
handle_cast(notify_node_up, State = #state{guid = GUID}) ->
434-
Nodes = rabbit_nodes:list_reachable() -- [node()],
435-
gen_server:abcast(Nodes, ?SERVER,
436-
{node_up, node(), rabbit_db_cluster:node_type(), GUID}),
437-
%% register other active rabbits with this rabbit
438-
DiskNodes = rabbit_db_cluster:disc_members(),
439-
[gen_server:cast(?SERVER, {node_up, N, case lists:member(N, DiskNodes) of
440-
true -> disc;
441-
false -> ram
442-
end}) || N <- Nodes],
433+
handle_cast(notify_node_up, State) ->
434+
do_notify_node_up(State),
443435
{noreply, State};
444436

445437
%%----------------------------------------------------------------------------
@@ -665,6 +657,12 @@ handle_info({nodedown, Node, Info}, State) ->
665657

666658
handle_info({nodeup, Node, _Info}, State) ->
667659
?LOG_INFO("node ~tp up", [Node]),
660+
%% We notify that `rabbit' is up here too (in addition from the message
661+
%% send explicitly by a boot step. That's because nodes may go down then
662+
%% up during a network partition, and with Khepri, nodes are not restarted
663+
%% (unlike with some partition handling strategies used with Mnesia), and
664+
%% thus the boot steps are not executed.
665+
do_notify_node_up(State),
668666
{noreply, State};
669667

670668
handle_info({mnesia_system_event,
@@ -854,6 +852,20 @@ wait_for_cluster_recovery(Condition) ->
854852
wait_for_cluster_recovery(Condition)
855853
end.
856854

855+
do_notify_node_up(#state{guid = GUID}) ->
856+
Nodes = rabbit_nodes:list_reachable() -- [node()],
857+
gen_server:abcast(Nodes, ?SERVER,
858+
{node_up, node(), rabbit_db_cluster:node_type(), GUID}),
859+
%% register other active rabbits with this rabbit
860+
DiskNodes = rabbit_db_cluster:disc_members(),
861+
_ = [gen_server:cast(
862+
?SERVER,
863+
{node_up, N, case lists:member(N, DiskNodes) of
864+
true -> disc;
865+
false -> ram
866+
end}) || N <- Nodes],
867+
ok.
868+
857869
handle_dead_rabbit(Node, State) ->
858870
%% TODO: This may turn out to be a performance hog when there are
859871
%% lots of nodes. We really only need to execute some of these

0 commit comments

Comments
 (0)