diff options
author | Rickard Green <rickard@erlang.org> | 2022-04-22 18:42:00 +0200 |
---|---|---|
committer | Rickard Green <rickard@erlang.org> | 2022-05-25 20:40:23 +0200 |
commit | 1d0fe6f71c320d2d1d19d9efd6dcba7b18bedca6 (patch) | |
tree | 379703319b813cd357121f8a049a6a10af6e0671 /lib | |
parent | b849e120e29c12183cf80c37fab628240bd456e7 (diff) | |
download | erlang-1d0fe6f71c320d2d1d19d9efd6dcba7b18bedca6.tar.gz |
[kernel] Introduce connect_all kernel parameter
Also fix the '-connect_all' command line argument.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/doc/src/global.xml | 15 | ||||
-rw-r--r-- | lib/kernel/doc/src/kernel_app.xml | 26 | ||||
-rw-r--r-- | lib/kernel/src/global.erl | 30 | ||||
-rw-r--r-- | lib/kernel/src/global_group.erl | 1 | ||||
-rw-r--r-- | lib/kernel/test/erl_distribution_SUITE.erl | 10 | ||||
-rw-r--r-- | lib/kernel/test/global_SUITE.erl | 16 |
6 files changed, 79 insertions, 19 deletions
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. </p> </warning> + <note> + <p> + None of the above services will be reliably delivered unless both of + the kernel parameters + <seealso marker="kernel_app#connect_all"><c>connect_all</c></seealso> + and <seealso marker="kernel_app#prevent_overlapping_partitions"> + <c>prevent_overlapping_partitions</c></seealso> are enabled. Calls to + the <c>global</c> API will, however, <i>not</i> fail even though one or + both of them are disabled. You will just get unreliable results. + </p> + </note> <p>These services are controlled through the process <c>global_name_server</c> that exists on every node. The global name server starts automatically when a node is started. @@ -108,9 +119,7 @@ example, if node <c>N1</c> connects to node <c>N2</c> (which is already connected to <c>N3</c>), the global name servers on the nodes <c>N1</c> and <c>N3</c> ensure that also <c>N1</c> - and <c>N3</c> are connected. If this is not desired, - command-line flag <c>-connect_all false</c> can be used (see also - <seealso marker="erts:erl#connect_all"><c>erl(1)</c></seealso>). + and <c>N3</c> are connected. In this case, the name registration service cannot be used, but the lock mechanism still works.</p> <p>If the global name server fails to connect nodes (<c>N1</c> 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 <seealso marker="app"><c>app(4)</c></seealso>.</p> <taglist> + <tag><marker id="connect_all"/> + <c>connect_all = true | false</c></tag> + <item> + <p> + If enabled (<c>true</c>), which also is the default, + <seealso marker="global"><c>global(3)</c></seealso> will + actively connect to all nodes that becomes known to it. Note + that you also want to enable + <seealso marker="#prevent_overlapping_partitions"> + <c>prevent_overlapping_partitions</c></seealso> in order for + <c>global</c> to ensure that a fully connected network + is maintained. <c>prevent_overlapping_partitions</c> + will also prevent inconsistencies in <c>global</c>'s + name registration and locking. Note that + <c>prevent_overlapping_partitions</c> currently is disabled + by default. + </p> + <p> + The now deprecated command line argument + <seealso marker="erts:erl#connect_all"><c>-connect_all + <boolean></c></seealso> has the same effect as the + <c>connect_all</c> configuration parameter. If this + configuration parameter is defined, it will override + the command line argument. + </p> + </item> <tag><c>distributed = [Distrib]</c></tag> <item> <p>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}}, |