From 8367be560025894f5eff504b3c03897e1dbac514 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Fri, 29 Sep 2023 12:17:08 +0200 Subject: [PATCH 1/9] Add which_volatile_backend_available function --- src/mongoose_cluster_id.erl | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/mongoose_cluster_id.erl b/src/mongoose_cluster_id.erl index 41fc3322251..75c7e6fa90a 100644 --- a/src/mongoose_cluster_id.erl +++ b/src/mongoose_cluster_id.erl @@ -17,14 +17,16 @@ -type cluster_id() :: binary(). -type maybe_cluster_id() :: {ok, cluster_id()} | {error, any()}. -type mongoose_backend() :: rdbms - | mnesia. + | mnesia + | cets. -spec start() -> maybe_cluster_id(). start() -> - init_mnesia_cache(), + init_cache(), Backend = which_backend_available(), + IntBackend = which_volatile_backend_available(), maybe_prepare_queries(Backend), - CachedRes = get_cached_cluster_id(), + CachedRes = get_cached_cluster_id(IntBackend), BackendRes = get_backend_cluster_id(), case {CachedRes, BackendRes} of {{ok, ID}, {ok, ID}} -> @@ -32,7 +34,7 @@ start() -> {{ok, ID}, {error, _}} -> set_new_cluster_id(ID, Backend); {{error, _}, {ok, ID}} -> - set_new_cluster_id(ID, mnesia); + set_new_cluster_id(ID, IntBackend); {{error, _}, {error, _}} -> make_and_set_new_cluster_id(); {{ok, CachedID}, {ok, BackendID}} -> @@ -45,6 +47,10 @@ start() -> %% Get cached version -spec get_cached_cluster_id() -> maybe_cluster_id(). get_cached_cluster_id() -> + IntBackend = which_volatile_backend_available(), + get_cached_cluster_id(IntBackend). + +get_cached_cluster_id(mnesia) -> T = fun() -> mnesia:read(mongoose_cluster_id, cluster_id) end, case mnesia:transaction(T) of {atomic, [#mongoose_cluster_id{value = ClusterID}]} -> @@ -74,7 +80,10 @@ make_and_set_new_cluster_id() -> %% ==================================================================== %% Internal functions %% ==================================================================== -init_mnesia_cache() -> +init_cache() -> + init_cache(which_volatile_backend_available()). + +init_cache(mnesia) -> mnesia:create_table(mongoose_cluster_id, [{type, set}, {record_name, mongoose_cluster_id}, @@ -104,15 +113,18 @@ make_cluster_id() -> -spec which_backend_available() -> mongoose_backend(). which_backend_available() -> case mongoose_wpool:get_pool_settings(rdbms, global, default) of - undefined -> mnesia; + undefined -> which_volatile_backend_available(); _ -> rdbms end. +which_volatile_backend_available() -> + mnesia. + -spec set_new_cluster_id(cluster_id(), mongoose_backend()) -> ok | {error, any()}. set_new_cluster_id(ID, rdbms) -> try execute_cluster_insert_new(ID) of {updated, 1} -> - set_new_cluster_id(ID, mnesia), + set_new_cluster_id(ID, which_volatile_backend_available()), {ok, ID} catch Class:Reason:Stacktrace -> From 16faaa4504424ed127eb3a90c8c6334b6e6e21c8 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Fri, 29 Sep 2023 12:51:52 +0200 Subject: [PATCH 2/9] Ensure Mnesia is stopped in CETS backend --- src/ejabberd_app.erl | 24 +----------- src/mongoose_internal_databases.erl | 61 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 src/mongoose_internal_databases.erl diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 7d02bba4f20..95e6bf22f3e 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -58,7 +58,7 @@ do_start() -> update_status_file(starting), mongoose_config:start(), mongoose_metrics:init(), - db_init(), + mongoose_internal_databases:init(), mongoose_graphql:init(), translate:start(), ejabberd_commands:init(), @@ -111,31 +111,9 @@ stop(_State) -> %% That is why we call mnesia:stop() inside of db_init_mnesia() instead. ok. - %%% %%% Internal functions %%% -db_init() -> - case mongoose_config:lookup_opt([internal_databases, mnesia]) of - {ok, _} -> - db_init_mnesia(), - mongoose_node_num_mnesia:init(); - {error, _} -> - ok - end. - -db_init_mnesia() -> - %% Mnesia should not be running at this point, unless it is started by tests. - %% Ensure Mnesia is stopped - mnesia:stop(), - case mnesia:system_info(extra_db_nodes) of - [] -> - mnesia:create_schema([node()]); - _ -> - ok - end, - application:start(mnesia, permanent), - mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity). -spec broadcast_c2s_shutdown_listeners() -> ok. broadcast_c2s_shutdown_listeners() -> diff --git a/src/mongoose_internal_databases.erl b/src/mongoose_internal_databases.erl new file mode 100644 index 00000000000..c7ffe98e715 --- /dev/null +++ b/src/mongoose_internal_databases.erl @@ -0,0 +1,61 @@ +-module(mongoose_internal_databases). +-export([init/0, + configured_internal_databases/0, + running_internal_databases/0]). + +-ignore_xref([configured_internal_databases/0, + running_internal_databases/0]). + +init() -> + case mongoose_config:lookup_opt([internal_databases, mnesia]) of + {ok, _} -> + init_mnesia(), + mongoose_node_num_mnesia:init(); + {error, _} -> + %% Ensure mnesia is stopped when applying the test presets from the big tests. + %% So, we accidentually do not test with mnesia enabled, when starting the + %% test cases from the clean test build. + mnesia:stop(), + ok + end. + +init_mnesia() -> + %% Mnesia should not be running at this point, unless it is started by tests. + %% Ensure Mnesia is stopped + mnesia:stop(), + case mnesia:system_info(extra_db_nodes) of + [] -> + mnesia:create_schema([node()]); + _ -> + ok + end, + application:start(mnesia, permanent), + mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity). + +configured_internal_databases() -> + case mongoose_config:lookup_opt([internal_databases, mnesia]) of + {ok, _} -> + [mnesia]; + {error, _} -> + [] + end ++ + case mongoose_config:lookup_opt([internal_databases, cets]) of + {ok, _} -> + [cets]; + {error, _} -> + [] + end. + +running_internal_databases() -> + case mnesia:system_info(is_running) of + yes -> + [mnesia]; + no -> + [] + end ++ + case is_pid(whereis(mongoose_cets_discovery)) of + true -> + [cets]; + false -> + [] + end. From e895cffae130860a42f4fd709a836efc149b8e65 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Fri, 29 Sep 2023 13:13:58 +0200 Subject: [PATCH 3/9] Add persistent_cluster_id_SUITE:clean_start_and_two_nodes/1 --- .../tests/persistent_cluster_id_SUITE.erl | 31 +++++++++++++++++-- src/mongoose_cluster_id.erl | 10 ++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/big_tests/tests/persistent_cluster_id_SUITE.erl b/big_tests/tests/persistent_cluster_id_SUITE.erl index fc8541cef8a..0478deb79a2 100644 --- a/big_tests/tests/persistent_cluster_id_SUITE.erl +++ b/big_tests/tests/persistent_cluster_id_SUITE.erl @@ -20,7 +20,8 @@ id_persists_after_restart/1, same_cluster_id_in_backend_and_mnesia/1, backed_up_id_if_rdbms_is_added/1, - cluster_id_is_restored_to_mnesia_from_rdbms_if_mnesia_lost/1 + cluster_id_is_restored_to_mnesia_from_rdbms_if_mnesia_lost/1, + clean_start_and_two_nodes/1 ]). -import(distributed_helper, [mim/0, mim2/0]). @@ -39,7 +40,8 @@ tests() -> id_persists_after_restart, same_cluster_id_in_backend_and_mnesia, backed_up_id_if_rdbms_is_added, - cluster_id_is_restored_to_mnesia_from_rdbms_if_mnesia_lost + cluster_id_is_restored_to_mnesia_from_rdbms_if_mnesia_lost, + clean_start_and_two_nodes ]. groups() -> @@ -52,7 +54,7 @@ groups() -> %%% Overall setup/teardown %%%=================================================================== init_per_suite(Config) -> - Config. + distributed_helper:require_rpc_nodes([mim]) ++ Config. end_per_suite(_Config) -> ok. @@ -144,3 +146,26 @@ cluster_id_is_restored_to_mnesia_from_rdbms_if_mnesia_lost(_Config) -> {ok, SecondID} = mongoose_helper:successful_rpc( Node, mongoose_cluster_id, get_cached_cluster_id, []), ?assertEqual(FirstID, SecondID). + +clean_start_and_two_nodes(_Config) -> + {ok, MnesiaID} = mongoose_helper:successful_rpc( + mim(), mongoose_cluster_id, get_cached_cluster_id, []), + {ok, MnesiaID2} = mongoose_helper:successful_rpc( + mim2(), mongoose_cluster_id, get_cached_cluster_id, []), + %% Sanity check: IDs are in sync + ?assertEqual(MnesiaID, MnesiaID2), + %% Remove an old ID from anywhere + ok = mongoose_helper:successful_rpc( + mim(), mongoose_cluster_id, clean_table, []), + ok = mongoose_helper:successful_rpc( + mim(), mongoose_cluster_id, clean_cache, []), + ok = mongoose_helper:successful_rpc( + mim2(), mongoose_cluster_id, clean_cache, []), + {ok, AfterRestartID} = mongoose_helper:successful_rpc( + mim(), mongoose_cluster_id, start, []), + {ok, AfterRestartID2} = mongoose_helper:successful_rpc( + mim2(), mongoose_cluster_id, start, []), + %% We've created a new ID + ?assertNotEqual(AfterRestartID, MnesiaID), + %% Both nodes have the same ID + ?assertEqual(AfterRestartID, AfterRestartID2). diff --git a/src/mongoose_cluster_id.erl b/src/mongoose_cluster_id.erl index 75c7e6fa90a..dbcb7ae18e5 100644 --- a/src/mongoose_cluster_id.erl +++ b/src/mongoose_cluster_id.erl @@ -9,9 +9,9 @@ ]). % For testing purposes only --export([clean_table/0]). +-export([clean_table/0, clean_cache/0]). --ignore_xref([clean_table/0, get_backend_cluster_id/0]). +-ignore_xref([clean_table/0, clean_cache/0, get_backend_cluster_id/0]). -record(mongoose_cluster_id, {key :: atom(), value :: cluster_id()}). -type cluster_id() :: binary(). @@ -178,3 +178,9 @@ clean_table(rdbms) -> {error, {Class, Reason}} end; clean_table(_) -> ok. + +clean_cache() -> + clean_cache(which_volatile_backend_available()). + +clean_cache(mnesia) -> + mnesia:dirty_delete(mongoose_cluster_id, cluster_id). From 54acb5ddf4463cba623d0384471d8cc85131e825 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 3 Oct 2023 10:36:40 +0200 Subject: [PATCH 4/9] Use cets:insert_serial/2 Fix errors in distributed_helper --- big_tests/tests/distributed_helper.erl | 25 +++++++++++++--- rebar.config | 2 +- rebar.lock | 2 +- src/mongoose_cluster_id.erl | 40 ++++++++++++++++++++++---- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/big_tests/tests/distributed_helper.erl b/big_tests/tests/distributed_helper.erl index b16d97d742a..f5e2ce544b4 100644 --- a/big_tests/tests/distributed_helper.erl +++ b/big_tests/tests/distributed_helper.erl @@ -24,20 +24,37 @@ add_node_to_cluster(Config) -> Node2 = mim2(), add_node_to_cluster(Node2, Config). +has_mnesia(Node) -> + DBs = rpc(Node, mongoose_internal_databases, configured_internal_databases, []), + lists:member(mnesia, DBs). + add_node_to_cluster(Node, Config) -> + case has_mnesia(Node) of + true -> + add_node_to_mnesia_cluster(Node, Config); + false -> + ok + end, + Config. + +add_node_to_mnesia_cluster(Node, Config) -> ClusterMemberNode = maps:get(node, mim()), ok = rpc(Node#{timeout => cluster_op_timeout()}, mongoose_cluster, join, [ClusterMemberNode]), - verify_result(Node, add), - Config. + verify_result(Node, add). remove_node_from_cluster(_Config) -> Node = mim2(), remove_node_from_cluster(Node, _Config). remove_node_from_cluster(Node, _Config) -> - ok = rpc(Node#{timeout => cluster_op_timeout()}, mongoose_cluster, leave, []), - verify_result(Node, remove), + case has_mnesia(Node) of + true -> + ok = rpc(Node#{timeout => cluster_op_timeout()}, mongoose_cluster, leave, []), + verify_result(Node, remove); + false -> + ok + end, ok. ctl_path(Node, Config) -> diff --git a/rebar.config b/rebar.config index 6279b700e14..92c1309f162 100644 --- a/rebar.config +++ b/rebar.config @@ -80,7 +80,7 @@ {cache_tab, "1.0.30"}, {segmented_cache, "0.3.0"}, {worker_pool, "6.0.1"}, - {cets, {git, "https://github.com/esl/cets.git", {branch, "main"}}}, + {cets, {git, "https://github.com/esl/cets.git", {branch, "feature/insert-serial"}}}, %%% HTTP tools {graphql, {git, "https://github.com/esl/graphql-erlang.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index 9d43179aa2e..aae73511993 100644 --- a/rebar.lock +++ b/rebar.lock @@ -8,7 +8,7 @@ {<<"certifi">>,{pkg,<<"certifi">>,<<"2.9.0">>},1}, {<<"cets">>, {git,"https://github.com/esl/cets.git", - {ref,"def7da28917fe7e21ad2b50d1b9939b1da5046cf"}}, + {ref,"c7c8124c294b606490dffcef8ef7b1fd66bdc47a"}}, 0}, {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},0}, {<<"cowboy_swagger">>,{pkg,<<"cowboy_swagger">>,<<"2.5.1">>},0}, diff --git a/src/mongoose_cluster_id.erl b/src/mongoose_cluster_id.erl index dbcb7ae18e5..56d628535a6 100644 --- a/src/mongoose_cluster_id.erl +++ b/src/mongoose_cluster_id.erl @@ -22,6 +22,9 @@ -spec start() -> maybe_cluster_id(). start() -> + %% Consider rewriting this logic, so it does not block the starting process. + %% Currently, we have to do an SQL query each time we restart MongooseIM + %% application in the tests. init_cache(), Backend = which_backend_available(), IntBackend = which_volatile_backend_available(), @@ -56,9 +59,16 @@ get_cached_cluster_id(mnesia) -> {atomic, [#mongoose_cluster_id{value = ClusterID}]} -> {ok, ClusterID}; {atomic, []} -> - {error, cluster_id_not_in_mnesia}; + {error, cluster_id_not_in_cache}; {aborted, Reason} -> {error, Reason} + end; +get_cached_cluster_id(cets) -> + case ets:lookup(cets_cluster_id, cluster_id) of + [{cluster_id, ClusterID}] -> + {ok, ClusterID}; + [] -> + {error, cluster_id_not_in_cache} end. %% ==================================================================== @@ -90,7 +100,13 @@ init_cache(mnesia) -> {attributes, record_info(fields, mongoose_cluster_id)}, {ram_copies, [node()]} ]), - mnesia:add_table_copy(mongoose_cluster_id, node(), ram_copies). + mnesia:add_table_copy(mongoose_cluster_id, node(), ram_copies); +init_cache(cets) -> + cets:start(cets_cluster_id, #{}), + cets_discovery:add_table(mongoose_cets_discovery, cets_cluster_id), + %% We have to do it, because we want to read from across the cluster + %% in the start/0 function. + ok = cets_discovery:wait_for_ready(mongoose_cets_discovery, infinity). -spec maybe_prepare_queries(mongoose_backend()) -> ok. maybe_prepare_queries(mnesia) -> ok; @@ -118,7 +134,12 @@ which_backend_available() -> end. which_volatile_backend_available() -> - mnesia. + case mongoose_config:get_opt(internal_databases) of + #{cets := _} -> + cets; + #{mnesia := _} -> + mnesia + end. -spec set_new_cluster_id(cluster_id(), mongoose_backend()) -> ok | {error, any()}. set_new_cluster_id(ID, rdbms) -> @@ -141,7 +162,10 @@ set_new_cluster_id(ID, mnesia) -> {ok, ID}; {aborted, Reason} -> {error, Reason} - end. + end; +set_new_cluster_id(ID, cets) -> + cets:insert_serial(cets_cluster_id, {cluster_id, ID}), + {ok, ID}. %% Get cluster ID -spec get_backend_cluster_id(mongoose_backend()) -> maybe_cluster_id(). @@ -157,7 +181,9 @@ get_backend_cluster_id(rdbms) -> {error, {Class, Reason}} end; get_backend_cluster_id(mnesia) -> - get_cached_cluster_id(). + get_cached_cluster_id(mnesia); +get_backend_cluster_id(cets) -> + get_cached_cluster_id(cets). clean_table() -> clean_table(which_backend_available()). @@ -183,4 +209,6 @@ clean_cache() -> clean_cache(which_volatile_backend_available()). clean_cache(mnesia) -> - mnesia:dirty_delete(mongoose_cluster_id, cluster_id). + mnesia:dirty_delete(mongoose_cluster_id, cluster_id); +clean_cache(cets) -> + cets:delete(cets_cluster_id, cluster_id). From be96cb9d164ad3d6fb1b2692494336e8837a3fdd Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 4 Oct 2023 12:35:36 +0200 Subject: [PATCH 5/9] Disable ensuring that mnesia is stopped temporary --- src/mongoose_internal_databases.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mongoose_internal_databases.erl b/src/mongoose_internal_databases.erl index c7ffe98e715..2395ce0fb45 100644 --- a/src/mongoose_internal_databases.erl +++ b/src/mongoose_internal_databases.erl @@ -15,7 +15,8 @@ init() -> %% Ensure mnesia is stopped when applying the test presets from the big tests. %% So, we accidentually do not test with mnesia enabled, when starting the %% test cases from the clean test build. - mnesia:stop(), + %% TODO Stopping here would break a lot of tests, stop here once tests are fixed. + % mnesia:stop(), ok end. From e536208680129042d494125db552583f5e5757a9 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 4 Oct 2023 15:37:44 +0200 Subject: [PATCH 6/9] Skip clusterSize test on CETS preset --- big_tests/tests/metrics_api_SUITE.erl | 9 +++++++-- doc/operation-and-maintenance/MongooseIM-metrics.md | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/big_tests/tests/metrics_api_SUITE.erl b/big_tests/tests/metrics_api_SUITE.erl index 39016129ade..b53efcb5848 100644 --- a/big_tests/tests/metrics_api_SUITE.erl +++ b/big_tests/tests/metrics_api_SUITE.erl @@ -71,8 +71,13 @@ end_per_group(GroupName, Config) -> metrics_helper:finalise_by_all_metrics_are_global(Config, GroupName =:= all_metrics_are_global). init_per_testcase(cluster_size = CN, Config) -> - Config1 = ensure_nodes_not_clustered(Config), - escalus:init_per_testcase(CN, Config1); + case distributed_helper:has_mnesia(mim()) of + true -> + Config1 = ensure_nodes_not_clustered(Config), + escalus:init_per_testcase(CN, Config1); + false -> + {skip, "Requires Mnesia"} + end; init_per_testcase(CaseName, Config) -> escalus:init_per_testcase(CaseName, Config). diff --git a/doc/operation-and-maintenance/MongooseIM-metrics.md b/doc/operation-and-maintenance/MongooseIM-metrics.md index 054afe9e88b..e7610ebf38d 100644 --- a/doc/operation-and-maintenance/MongooseIM-metrics.md +++ b/doc/operation-and-maintenance/MongooseIM-metrics.md @@ -153,7 +153,7 @@ Metrics specific to an extension, e.g. Message Archive Management, are described | `[global, uniqueSessionCount]` | value | A number of unique users connected to a MongooseIM cluster (e.g. 3 sessions of the same user will be counted as 1 in this metric). | | `[global, cache, unique_sessions_number]` | gauge | A cached value of `uniqueSessionCount`. It is automatically updated when a unique session count is calculated. | | `[global, nodeUpTime]` | value | Node uptime. | -| `[global, clusterSize]` | value | A number of nodes in a MongooseIM cluster seen by a given MongooseIM node. | +| `[global, clusterSize]` | value | A number of nodes in a MongooseIM cluster seen by a given MongooseIM node (based on Mnesia). For CETS use `global.cets.system.joined_nodes` instead. | | `[global, tcpPortsUsed]` | value | A number of open tcp connections. This should relate to the number of connected sessions and databases, as well as federations and http requests, in order to detect connection leaks. | | `[global, processQueueLengths]` | probe | The number of queued messages in the internal message queue of every erlang process, and the internal queue of every fsm (ejabberd\_c2s). This is sampled every 30 seconds asynchronously. It is a good indicator of an overloaded system: if too many messages are queued at the same time, the system is not able to process the data at the rate it was designed for. | From f807668820ca2dbc55227c5b7fd84279e978dd75 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 4 Oct 2023 16:41:36 +0200 Subject: [PATCH 7/9] Fix graphql_server_SUITE:admin_http:clustering_http_tests:remove_alive_from_cluster_http --- big_tests/tests/distributed_helper.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/big_tests/tests/distributed_helper.erl b/big_tests/tests/distributed_helper.erl index f5e2ce544b4..4cf58b8315c 100644 --- a/big_tests/tests/distributed_helper.erl +++ b/big_tests/tests/distributed_helper.erl @@ -25,7 +25,9 @@ add_node_to_cluster(Config) -> add_node_to_cluster(Node2, Config). has_mnesia(Node) -> - DBs = rpc(Node, mongoose_internal_databases, configured_internal_databases, []), + %% It is shometimes called, when MIM application is stopped, + %% so we use running_internal_databases instead of configured_internal_databases. + DBs = rpc(Node, mongoose_internal_databases, running_internal_databases, []), lists:member(mnesia, DBs). add_node_to_cluster(Node, Config) -> From acf63560285c0985cccd7a518ae5b8cd12774c44 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Fri, 6 Oct 2023 12:54:49 +0200 Subject: [PATCH 8/9] Use main branch of CETS --- rebar.config | 2 +- rebar.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rebar.config b/rebar.config index 92c1309f162..6279b700e14 100644 --- a/rebar.config +++ b/rebar.config @@ -80,7 +80,7 @@ {cache_tab, "1.0.30"}, {segmented_cache, "0.3.0"}, {worker_pool, "6.0.1"}, - {cets, {git, "https://github.com/esl/cets.git", {branch, "feature/insert-serial"}}}, + {cets, {git, "https://github.com/esl/cets.git", {branch, "main"}}}, %%% HTTP tools {graphql, {git, "https://github.com/esl/graphql-erlang.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index aae73511993..8fd97dd4593 100644 --- a/rebar.lock +++ b/rebar.lock @@ -8,7 +8,7 @@ {<<"certifi">>,{pkg,<<"certifi">>,<<"2.9.0">>},1}, {<<"cets">>, {git,"https://github.com/esl/cets.git", - {ref,"c7c8124c294b606490dffcef8ef7b1fd66bdc47a"}}, + {ref,"e3ad43f3836ea457bcb54e2f8266e9d7c32b014f"}}, 0}, {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},0}, {<<"cowboy_swagger">>,{pkg,<<"cowboy_swagger">>,<<"2.5.1">>},0}, From 48f1203989fc98de3266529b4e57495b17d22aad Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Fri, 6 Oct 2023 13:03:20 +0200 Subject: [PATCH 9/9] Remove configured_internal_databases/0, running_internal_databases/0 --- big_tests/tests/distributed_helper.erl | 8 +++--- src/mongoose_internal_databases.erl | 35 +------------------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/big_tests/tests/distributed_helper.erl b/big_tests/tests/distributed_helper.erl index 4cf58b8315c..4336348505a 100644 --- a/big_tests/tests/distributed_helper.erl +++ b/big_tests/tests/distributed_helper.erl @@ -25,10 +25,10 @@ add_node_to_cluster(Config) -> add_node_to_cluster(Node2, Config). has_mnesia(Node) -> - %% It is shometimes called, when MIM application is stopped, - %% so we use running_internal_databases instead of configured_internal_databases. - DBs = rpc(Node, mongoose_internal_databases, running_internal_databases, []), - lists:member(mnesia, DBs). + %% TODO We should check that Mnesia is configured here instead of is_running. + %% But it would require the issue fixed first: + %% "MIM-2067 Actually disable mnesia from starting in tests in pgsql_cets" + rpc(Node, mnesia, system_info, [is_running]) =:= yes. add_node_to_cluster(Node, Config) -> case has_mnesia(Node) of diff --git a/src/mongoose_internal_databases.erl b/src/mongoose_internal_databases.erl index 2395ce0fb45..79eb4ff88f1 100644 --- a/src/mongoose_internal_databases.erl +++ b/src/mongoose_internal_databases.erl @@ -1,10 +1,5 @@ -module(mongoose_internal_databases). --export([init/0, - configured_internal_databases/0, - running_internal_databases/0]). - --ignore_xref([configured_internal_databases/0, - running_internal_databases/0]). +-export([init/0]). init() -> case mongoose_config:lookup_opt([internal_databases, mnesia]) of @@ -32,31 +27,3 @@ init_mnesia() -> end, application:start(mnesia, permanent), mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity). - -configured_internal_databases() -> - case mongoose_config:lookup_opt([internal_databases, mnesia]) of - {ok, _} -> - [mnesia]; - {error, _} -> - [] - end ++ - case mongoose_config:lookup_opt([internal_databases, cets]) of - {ok, _} -> - [cets]; - {error, _} -> - [] - end. - -running_internal_databases() -> - case mnesia:system_info(is_running) of - yes -> - [mnesia]; - no -> - [] - end ++ - case is_pid(whereis(mongoose_cets_discovery)) of - true -> - [cets]; - false -> - [] - end.