diff options
| author | Michael Klishin <michael@clojurewerkz.org> | 2020-06-02 04:10:08 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2020-06-02 04:10:14 +0300 |
| commit | 2d4bce218988aaa43c2318c3864bc5a9f84a2cb8 (patch) | |
| tree | abd27164cd45868cd650b3a214aa2e1de2f34f8e /src | |
| parent | 9083a01b59195bf1202b74f504b5ae47ba110a6a (diff) | |
| download | rabbitmq-server-git-2d4bce218988aaa43c2318c3864bc5a9f84a2cb8.tar.gz | |
rabbit_mnesia:is_virgin_node/0: take overridden Ra data directory into account
as well as the default location because it can exist for various reasons
early on node startup.
Part of rabbitmq/rabbitmq-server#2317
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_mnesia.erl | 9 | ||||
| -rw-r--r-- | src/rabbit_node_monitor.erl | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index b7db646dad..7973748a01 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -558,6 +558,7 @@ dir() -> mnesia:system_info(directory). %% file. init_db(ClusterNodes, NodeType, CheckOtherNodes) -> NodeIsVirgin = is_virgin_node(), + rabbit_log:debug("Does data directory looks like that of a blank (uninitialised) node? ~p", [NodeIsVirgin]), Nodes = change_extra_db_nodes(ClusterNodes, CheckOtherNodes), %% Note that we use `system_info' here and not the cluster status %% since when we start rabbit for the first time the cluster @@ -1008,8 +1009,8 @@ check_rabbit_consistency(RemoteNode, RemoteVersion) -> %% mnesia tables aren't there because restarted RAM nodes won't have %% tables while still being non-virgin. What we do instead is to %% check if the mnesia directory is non existent or empty, with the -%% exception of the cluster status files, which will be there thanks to -%% `rabbit_node_monitor:prepare_cluster_status_file/0'. +%% exception of certain files and directories, which can be there very early +%% on node boot. is_virgin_node() -> case rabbit_file:list_dir(dir()) of {error, enoent} -> @@ -1020,10 +1021,14 @@ is_virgin_node() -> IgnoredFiles0 = [rabbit_node_monitor:cluster_status_filename(), rabbit_node_monitor:running_nodes_filename(), + rabbit_node_monitor:default_quorum_filename(), rabbit_node_monitor:quorum_filename(), rabbit_feature_flags:enabled_feature_flags_list_file()], IgnoredFiles = [filename:basename(File) || File <- IgnoredFiles0], + rabbit_log:debug("Files and directories found in node's data directory: ~s, of them to be ignored: ~s", + [string:join(lists:usort(List0), ", "), string:join(lists:usort(IgnoredFiles), ", ")]), List = List0 -- IgnoredFiles, + rabbit_log:debug("Files and directories found in node's data directory sans ignored ones: ~s", [string:join(lists:usort(List), ", ")]), List =:= [] end. diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index e142adebdb..ed1d30272e 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -24,7 +24,7 @@ -export([start_link/0]). -export([running_nodes_filename/0, - cluster_status_filename/0, quorum_filename/0, + cluster_status_filename/0, quorum_filename/0, default_quorum_filename/0, prepare_cluster_status_files/0, write_cluster_status/1, read_cluster_status/0, update_cluster_status/0, reset_cluster_status/0]). @@ -82,6 +82,9 @@ cluster_status_filename() -> filename:join(rabbit_mnesia:dir(), "cluster_nodes.config"). quorum_filename() -> + ra_env:data_dir(). + +default_quorum_filename() -> filename:join(rabbit_mnesia:dir(), "quorum"). -spec prepare_cluster_status_files() -> 'ok' | no_return(). |
