From 1d0fe6f71c320d2d1d19d9efd6dcba7b18bedca6 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Fri, 22 Apr 2022 18:42:00 +0200 Subject: [kernel] Introduce connect_all kernel parameter Also fix the '-connect_all' command line argument. --- lib/kernel/doc/src/global.xml | 15 ++++++++++++--- lib/kernel/doc/src/kernel_app.xml | 26 ++++++++++++++++++++++++++ lib/kernel/src/global.erl | 30 +++++++++++++++++++++--------- lib/kernel/src/global_group.erl | 1 - lib/kernel/test/erl_distribution_SUITE.erl | 10 ++++++++-- lib/kernel/test/global_SUITE.erl | 16 ++++++++++++---- 6 files changed, 79 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/kernel/doc/src/global.xml b/lib/kernel/doc/src/global.xml index b8385436b5..afe7ea793b 100644 --- a/lib/kernel/doc/src/global.xml +++ b/lib/kernel/doc/src/global.xml @@ -70,6 +70,17 @@ enabled by default.

+ +

+ None of the above services will be reliably delivered unless both of + the kernel parameters + connect_all + and + prevent_overlapping_partitions are enabled. Calls to + the global API will, however, not fail even though one or + both of them are disabled. You will just get unreliable results. +

+

These services are controlled through the process global_name_server that exists on every node. The global name server starts automatically when a node is started. @@ -108,9 +119,7 @@ example, if node N1 connects to node N2 (which is already connected to N3), the global name servers on the nodes N1 and N3 ensure that also N1 - and N3 are connected. If this is not desired, - command-line flag -connect_all false can be used (see also - erl(1)). + and N3 are connected. In this case, the name registration service cannot be used, but the lock mechanism still works.

If the global name server fails to connect nodes (N1 and diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index aef5a9fbe2..d3aee7630c 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -121,6 +121,32 @@ application. For more information about configuration parameters, see file app(4).

+ + connect_all = true | false + +

+ If enabled (true), which also is the default, + global(3) will + actively connect to all nodes that becomes known to it. Note + that you also want to enable + + prevent_overlapping_partitions in order for + global to ensure that a fully connected network + is maintained. prevent_overlapping_partitions + will also prevent inconsistencies in global's + name registration and locking. Note that + prevent_overlapping_partitions currently is disabled + by default. +

+

+ The now deprecated command line argument + -connect_all + <boolean> has the same effect as the + connect_all configuration parameter. If this + configuration parameter is defined, it will override + the command line argument. +

+
distributed = [Distrib]

Specifies which applications that are distributed and on which diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl index f61ccb1c56..0c100136e2 100644 --- a/lib/kernel/src/global.erl +++ b/lib/kernel/src/global.erl @@ -546,23 +546,35 @@ init([]) -> no_trace end, - Ca = case init:get_argument(connect_all) of - {ok, [["false"]]} -> - false; - _ -> - true + Ca = case application:get_env(kernel, connect_all) of + {ok, CaBool} when is_boolean(CaBool) -> + CaBool; + {ok, CaInvalid} -> + error({invalid_parameter_value, connect_all, CaInvalid}); + undefined -> + CaBool = case init:get_argument(connect_all) of + {ok, [["false" | _] | _]} -> + false; + _ -> + true + end, + ok = application:set_env(kernel, connect_all, CaBool, + [{timeout, infinity}]), + CaBool end, + POP = case application:get_env(kernel, prevent_overlapping_partitions) of - {ok, Bool} when Bool == true; Bool == false -> - Bool; - {ok, Invalid} -> + {ok, PopBool} when is_boolean(PopBool) -> + PopBool; + {ok, PopInvalid} -> error({invalid_parameter_value, prevent_overlapping_partitions, - Invalid}); + PopInvalid}); undefined -> false end, + S = #state{the_locker = start_the_locker(DoTrace), known = Known, trace = T0, diff --git a/lib/kernel/src/global_group.erl b/lib/kernel/src/global_group.erl index daaaff61d8..69f3f367eb 100644 --- a/lib/kernel/src/global_group.erl +++ b/lib/kernel/src/global_group.erl @@ -85,7 +85,6 @@ %%%==================================================================================== -record(state, {sync_state = no_conf :: sync_state(), - connect_all :: boolean(), group_name = [] :: group_name() | [], nodes = #{} :: #{node() => node_state()}, other_grps = [], diff --git a/lib/kernel/test/erl_distribution_SUITE.erl b/lib/kernel/test/erl_distribution_SUITE.erl index 7d7108e44b..a22635dd68 100644 --- a/lib/kernel/test/erl_distribution_SUITE.erl +++ b/lib/kernel/test/erl_distribution_SUITE.erl @@ -771,8 +771,14 @@ run_tick_change_test(DCfg, B, C, PrevTT, TT) -> hidden_node(Config) when is_list(Config) -> run_dist_configs(fun hidden_node/2, Config). -hidden_node(DCfg, _Config) -> - HArgs = "-hidden", +hidden_node(DCfg, Config) -> + hidden_node(DCfg, "-hidden", Config), + hidden_node(DCfg, "-hidden -hidden", Config), + hidden_node(DCfg, "-hidden true -hidden true", Config), + ok. + +hidden_node(DCfg, HArgs, _Config) -> + ct:pal("--- Hidden argument(s): ~s~n", [HArgs]), {ok, V} = start_node(DCfg, visible_node), VMN = start_monitor_nodes_proc(V), {ok, H} = start_node(DCfg, hidden_node, HArgs), diff --git a/lib/kernel/test/global_SUITE.erl b/lib/kernel/test/global_SUITE.erl index 1a597c2fb2..769e4ec23e 100644 --- a/lib/kernel/test/global_SUITE.erl +++ b/lib/kernel/test/global_SUITE.erl @@ -30,7 +30,7 @@ ring/1, simple_ring/1, line/1, simple_line/1, global_lost_nodes/1, otp_1849/1, otp_3162/1, otp_5640/1, otp_5737/1, - otp_6931/1, + connect_all_false/1, simple_disconnect/1, simple_resolve/1, simple_resolve2/1, simple_resolve3/1, leftover_name/1, re_register_name/1, name_exit/1, external_nodes/1, @@ -77,7 +77,7 @@ all() -> advanced_partition, basic_name_partition, stress_partition, simple_ring, simple_line, ring, line, global_lost_nodes, otp_1849, otp_3162, otp_5640, - otp_5737, otp_6931, simple_disconnect, simple_resolve, + otp_5737, connect_all_false, simple_disconnect, simple_resolve, simple_resolve2, simple_resolve3, leftover_name, re_register_name, name_exit, external_nodes, many_nodes, sync_0, global_groups_change, register_1, both_known_1, @@ -2067,10 +2067,18 @@ otp_5737(Config) when is_list(Config) -> init_condition(Config), ok. -%% OTP-6931. Ignore nodeup when connect_all=false. -otp_6931(Config) when is_list(Config) -> +connect_all_false(Config) when is_list(Config) -> + %% OTP-6931. Ignore nodeup when connect_all=false. + connect_all_false_test("-connect_all false", Config), + %% OTP-17934: multipl -connect_all false and kernel parameter connect_all + connect_all_false_test("-connect_all false -connect_all false", Config), + connect_all_false_test("-kernel connect_all false", Config), + ok. + +connect_all_false_test(CAArg, Config) -> Me = self(), {ok, CAf} = start_non_connecting_node(ca_false, Config), + {ok, false} = rpc:call(CAf, application, get_env, [kernel, connect_all]), ok = rpc:call(CAf, error_logger, add_report_handler, [?MODULE, Me]), info = rpc:call(CAf, error_logger, warning_map, []), {global_name_server,CAf} ! {nodeup, fake_node, #{connection_id => 4711}}, -- cgit v1.2.1