Просмотр исходного кода

Merge pull request #9663 from zmstone/0102-fix-stopped-nodes-detection

0102 fix stopped nodes detection
Zaiming (Stone) Shi 3 лет назад
Родитель
Сommit
5653d113ac

+ 4 - 6
apps/emqx_conf/src/emqx_cluster_rpc.erl

@@ -512,7 +512,7 @@ do_alarm(Fun, Res, #{tnx_id := Id} = Meta) ->
 
 wait_for_all_nodes_commit(TnxId, Delay, Remain) ->
     Lagging = lagging_nodes(TnxId),
-    Stopped = stopped_nodes(),
+    Stopped = Lagging -- mria_mnesia:running_nodes(),
     case Lagging -- Stopped of
         [] when Stopped =:= [] ->
             ok;
@@ -537,9 +537,10 @@ wait_for_nodes_commit(RequiredSyncs, TnxId, Delay, Remain) ->
                 [] ->
                     ok;
                 Lagging ->
-                    case stopped_nodes() of
+                    Stopped = Lagging -- mria_mnesia:running_nodes(),
+                    case Stopped of
                         [] -> {peers_lagging, Lagging};
-                        Stopped -> {stopped_nodes, Stopped}
+                        _ -> {stopped_nodes, Stopped}
                     end
             end
     end.
@@ -558,9 +559,6 @@ commit_status_trans(Operator, TnxId) ->
     Result = '$2',
     mnesia:select(?CLUSTER_COMMIT, [{MatchHead, [Guard], [Result]}]).
 
-stopped_nodes() ->
-    ekka_cluster:info(stopped_nodes).
-
 get_retry_ms() ->
     emqx_conf:get([node, cluster_call, retry_interval], timer:minutes(1)).
 

+ 1 - 1
apps/emqx_conf/src/emqx_conf.app.src

@@ -1,6 +1,6 @@
 {application, emqx_conf, [
     {description, "EMQX configuration management"},
-    {vsn, "0.1.8"},
+    {vsn, "0.1.9"},
     {registered, []},
     {mod, {emqx_conf_app, []}},
     {applications, [kernel, stdlib]},

+ 3 - 0
apps/emqx_conf/test/emqx_cluster_rpc_SUITE.erl

@@ -48,11 +48,14 @@ init_per_suite(Config) ->
     meck:new(emqx_alarm, [non_strict, passthrough, no_link]),
     meck:expect(emqx_alarm, activate, 3, ok),
     meck:expect(emqx_alarm, deactivate, 3, ok),
+    meck:new(mria_mnesia, [non_strict, passthrough, no_link]),
+    meck:expect(mria_mnesia, running_nodes, 0, [?NODE1, {node(), ?NODE2}, {node(), ?NODE3}]),
     Config.
 
 end_per_suite(_Config) ->
     ekka:stop(),
     mria:stop(),
+    meck:unload(mria_mnesia),
     mria_mnesia:delete_schema(),
     meck:unload(emqx_alarm),
     ok.