fix(emqx_router_helper): don't cleanup down node on a replicant

The cleanup on a replicant node is redundant, as Mria would delegate this delete op
to a core node (via RPC), and the core node is expected to receive the same
`nodedown` message and process it.
This commit is contained in:
Serge Tupchii 2023-08-04 16:55:36 +03:00
parent f276ea9e91
commit 2b7798608d
1 changed files with 12 additions and 7 deletions

View File

@ -146,13 +146,18 @@ handle_info({mnesia_table_event, Event}, State) ->
?SLOG(debug, #{msg => "unexpected_mnesia_table_event", event => Event}), ?SLOG(debug, #{msg => "unexpected_mnesia_table_event", event => Event}),
{noreply, State}; {noreply, State};
handle_info({nodedown, Node}, State = #{nodes := Nodes}) -> handle_info({nodedown, Node}, State = #{nodes := Nodes}) ->
global:trans( case mria_rlog:role() of
{?LOCK, self()}, core ->
fun() -> global:trans(
mria:transaction(?ROUTE_SHARD, fun ?MODULE:cleanup_routes/1, [Node]) {?LOCK, self()},
end fun() ->
), mria:transaction(?ROUTE_SHARD, fun ?MODULE:cleanup_routes/1, [Node])
ok = mria:dirty_delete(?ROUTING_NODE, Node), end
),
ok = mria:dirty_delete(?ROUTING_NODE, Node);
replicant ->
ok
end,
?tp(emqx_router_helper_cleanup_done, #{node => Node}), ?tp(emqx_router_helper_cleanup_done, #{node => Node}),
{noreply, State#{nodes := lists:delete(Node, Nodes)}, hibernate}; {noreply, State#{nodes := lists:delete(Node, Nodes)}, hibernate};
handle_info({membership, {mnesia, down, Node}}, State) -> handle_info({membership, {mnesia, down, Node}}, State) ->