Skip to content

Commit

Permalink
Merge pull request #10313 from JimMoen/fix-cluster-node-selected
Browse files Browse the repository at this point in the history
fix: running nodes should not include replica nodes
  • Loading branch information
JimMoen committed Apr 3, 2023
2 parents 7c60a1e + 53712e6 commit 5b10937
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/emqx_conf/src/emqx_conf.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, emqx_conf, [
{description, "EMQX configuration management"},
{vsn, "0.1.14"},
{vsn, "0.1.15"},
{registered, []},
{mod, {emqx_conf_app, []}},
{applications, [kernel, stdlib, emqx_ctl]},
Expand Down
10 changes: 5 additions & 5 deletions apps/emqx_conf/src/emqx_conf_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ init_conf() ->
emqx_app:set_init_config_load_done().

cluster_nodes() ->
maps:get(running_nodes, ekka_cluster:info()) -- [node()].
mria_mnesia:running_nodes() -- [node()].

copy_override_conf_from_core_node() ->
case cluster_nodes() of
%% The first core nodes is self.
[] ->
?SLOG(debug, #{msg => "skip_copy_overide_conf_from_core_node"}),
?SLOG(debug, #{msg => "skip_copy_override_conf_from_core_node"}),
{ok, ?DEFAULT_INIT_TXN_ID};
Nodes ->
{Results, Failed} = emqx_conf_proto_v2:get_override_config_file(Nodes),
Expand Down Expand Up @@ -130,7 +130,7 @@ copy_override_conf_from_core_node() ->
%% finish the boot sequence and load the
%% config for other nodes to copy it.
?SLOG(info, #{
msg => "skip_copy_overide_conf_from_core_node",
msg => "skip_copy_override_conf_from_core_node",
loading_from_disk => true,
nodes => Nodes,
failed => Failed,
Expand All @@ -142,7 +142,7 @@ copy_override_conf_from_core_node() ->
Jitter = rand:uniform(2_000),
Timeout = 10_000 + Jitter,
?SLOG(info, #{
msg => "copy_overide_conf_from_core_node_retry",
msg => "copy_override_conf_from_core_node_retry",
timeout => Timeout,
nodes => Nodes,
failed => Failed,
Expand All @@ -155,7 +155,7 @@ copy_override_conf_from_core_node() ->
[{ok, Info} | _] = lists:sort(fun conf_sort/2, Ready),
#{node := Node, conf := RawOverrideConf, tnx_id := TnxId} = Info,
?SLOG(debug, #{
msg => "copy_overide_conf_from_core_node_success",
msg => "copy_override_conf_from_core_node_success",
node => Node,
cluster_override_conf_file => application:get_env(
emqx, cluster_override_conf_file
Expand Down
2 changes: 2 additions & 0 deletions changes/ce/fix-10313.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ensure that when the core or replicant node starting, the `cluster-override.conf` file is only copied from the core node.
Previously, when sorting nodes by startup time, the core node may have copied this file from the replicant node.
2 changes: 2 additions & 0 deletions changes/ce/fix-10313.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
确保当 core 或 replicant 节点启动时,仅从 core 节点复制 `cluster-override.conf` 文件。
此前按照节点启动时间排序时,core 节点可能从 replicant 节点复制该文件。

0 comments on commit 5b10937

Please sign in to comment.