From 4f35fdba5a1fd7ada1df4157c66fc72fed3a5aaa Mon Sep 17 00:00:00 2001 From: Michal Kuratczyk Date: Wed, 24 Apr 2024 11:16:35 +0200 Subject: [PATCH] Speed up stop_app I noticed that `stop_app` would take over 5 seconds on an empty node which is strange. I found this gap in the logs: ``` 2024-04-18 10:49:04.646450+09:00 [info] <0.599.0> Management plugin: to stop collect_statistics. 2024-04-18 10:49:09.647652+09:00 [debug] <0.247.0> Set stop reason to: normal ``` No point waiting for that stats to stop being emitted when we stop the node completely. It was added in https://github.com/rabbitmq/rabbitmq-server/commit/0e640da5 to ensure the stats stop when the management_agent gets disabled --- deps/rabbitmq_management_agent/src/rabbit_mgmt_db_handler.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deps/rabbitmq_management_agent/src/rabbit_mgmt_db_handler.erl b/deps/rabbitmq_management_agent/src/rabbit_mgmt_db_handler.erl index d76655ace063..09183e1875e7 100644 --- a/deps/rabbitmq_management_agent/src/rabbit_mgmt_db_handler.erl +++ b/deps/rabbitmq_management_agent/src/rabbit_mgmt_db_handler.erl @@ -92,6 +92,10 @@ handle_event(_, State) -> handle_info(_Info, State) -> {ok, State}. +terminate(stop, _State) -> + %% if the node is stopping, we don't want to wait + %% 5 seconds for the statistics to get disabled + ok; terminate(_Arg, _State) -> ensure_statistics_disabled(), ok.