Pārlūkot izejas kodu

fix(nodetool): increase graceful stop timeout, handle and report `{badrpc, timeout}` error

Serge Tupchii 2 gadi atpakaļ
vecāks
revīzija
9de9631d6b
2 mainītis faili ar 11 papildinājumiem un 1 dzēšanām
  1. 8 1
      bin/nodetool
  2. 3 0
      changes/ce/fix-11567.en.md

+ 8 - 1
bin/nodetool

@@ -8,6 +8,8 @@
 %% -------------------------------------------------------------------
 -mode(compile).
 
+-define(SHUTDOWN_TIMEOUT_MS, 120_000).
+
 main(Args) ->
     case os:type() of
         {win32, nt} -> ok;
@@ -85,9 +87,14 @@ do(Args) ->
             %% a "pong"
             io:format("pong\n");
         ["stop"] ->
-            case rpc:call(TargetNode, emqx_machine, graceful_shutdown, [], 60000) of
+            case rpc:call(TargetNode, emqx_machine, graceful_shutdown, [], ?SHUTDOWN_TIMEOUT_MS) of
                 ok ->
                     ok;
+                {badrpc, timeout} ->
+                    io:format("EMQX is still shutting down, it failed to stop gracefully "
+                              "within the configured timeout of: ~ps\n",
+                              [erlang:convert_time_unit(?SHUTDOWN_TIMEOUT_MS, millisecond, second)]),
+                    halt(1);
                 {badrpc, nodedown} ->
                     %% nodetool commands are always executed after a ping
                     %% which if the code gets here, it's because the target node

+ 3 - 0
changes/ce/fix-11567.en.md

@@ -0,0 +1,3 @@
+Improve EMQX graceful shutdown (`emqx stop` command):
+- increase timeout from 1 to 2 minutes
+- print an error message if EMQX can't stop gracefully within the configured timeout