فهرست منبع

chore: add comment for init_loader_done

zhongwencool 2 سال پیش
والد
کامیت
802a50601a
3فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 2 0
      apps/emqx/src/emqx_listeners.erl
  2. 6 0
      apps/emqx_conf/src/emqx_conf_app.erl
  3. 1 1
      apps/emqx_machine/src/emqx_machine_boot.erl

+ 2 - 0
apps/emqx/src/emqx_listeners.erl

@@ -96,6 +96,8 @@ format_list(Listener) ->
 
 do_list_raw() ->
     %% GET /listeners from other nodes returns [] when init config is not loaded.
+    %% FIXME This is a workaround for the issue:
+    %% mria:running_nodes() sometime return node which not ready to accept rpc call.
     case emqx_app:init_load_done() of
         true ->
             Key = <<"listeners">>,

+ 6 - 0
apps/emqx_conf/src/emqx_conf_app.erl

@@ -21,6 +21,7 @@
 -export([start/2, stop/1]).
 -export([get_override_config_file/0]).
 -export([sync_data_from_node/0]).
+-export([unset_config_loaded/0]).
 
 -include_lib("emqx/include/logger.hrl").
 -include("emqx_conf.hrl").
@@ -42,6 +43,11 @@ start(_StartType, _StartArgs) ->
 stop(_State) ->
     ok.
 
+%% @doc emqx_conf relies on this flag to synchronize configuration between nodes.
+%% Therefore, we must clean up this flag when emqx application is restarted by mria.
+unset_config_loaded() ->
+    emqx_app:unset_config_loaded().
+
 %% Read the cluster config from the local node.
 %% This function is named 'override' due to historical reasons.
 get_override_config_file() ->

+ 1 - 1
apps/emqx_machine/src/emqx_machine_boot.erl

@@ -61,7 +61,7 @@ start_autocluster() ->
 stop_apps() ->
     ?SLOG(notice, #{msg => "stopping_emqx_apps"}),
     _ = emqx_alarm_handler:unload(),
-    ok = emqx_app:unset_config_loaded(),
+    ok = emqx_conf_app:unset_config_loaded(),
     lists:foreach(fun stop_one_app/1, lists:reverse(sorted_reboot_apps())).
 
 %% Those port apps are terminated after the main apps