summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2013-12-06 12:31:22 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2013-12-06 12:31:22 +0000
commit08c6e4053b517a54f34ccad447e7076cfcb2b16c (patch)
tree537aef66778e9bde5457c3caec2301d890a710a8
parente49c748ce7abc252fb12e7211572d21780de104e (diff)
downloadrabbitmq-server-08c6e4053b517a54f34ccad447e7076cfcb2b16c.tar.gz
Undo some changes.
-rw-r--r--src/rabbit_mnesia.erl34
-rw-r--r--src/rabbit_version.erl19
2 files changed, 11 insertions, 42 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index 8147a91a..3a8fae7f 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -434,9 +434,10 @@ init_db(ClusterNodes, NodeType, CheckOtherNodes) ->
%% First disc node up
maybe_force_load(),
ok;
- {[_ | _], _, _} ->
+ {[AnotherNode | _], _, _} ->
%% Subsequent node in cluster, catch up
- ok = ensure_version_ok(Nodes),
+ ensure_version_ok(
+ rpc:call(AnotherNode, rabbit_version, recorded, [])),
maybe_force_load(),
ok = rabbit_table:wait_for_replicated(),
ok = rabbit_table:create_local_copy(NodeType)
@@ -638,29 +639,14 @@ schema_ok_or_move() ->
ok = create_schema()
end.
-ensure_version_ok(OtherNodes) ->
- Desired = rabbit_version:desired(),
- Fun = fun (Node, FoundMatch) ->
- case rpc:call(Node, rabbit_version, recorded, []) of
- {error, _} ->
- FoundMatch; %% Node probably isn't fully up.
- {ok, NodeVersion} ->
- case rabbit_version:compare(Desired, NodeVersion) of
- eq ->
- true;
- gt ->
- FoundMatch; %% Remote is just older than us.
- _ ->
- throw({error, {version_mismatch,
- Desired, NodeVersion}})
- end
- end
- end,
- FoundMatch = lists:foldl(Fun, false, OtherNodes),
- case FoundMatch of
+ensure_version_ok({ok, DiscVersion}) ->
+ DesiredVersion = rabbit_version:desired(),
+ case rabbit_version:matches(DesiredVersion, DiscVersion) of
true -> ok;
- false -> throw({error, {version_mismatch, Desired}})
- end.
+ false -> throw({error, {version_mismatch, DesiredVersion, DiscVersion}})
+ end;
+ensure_version_ok({error, _}) ->
+ ok = rabbit_version:record_desired().
%% We only care about disc nodes since ram nodes are supposed to catch
%% up only
diff --git a/src/rabbit_version.erl b/src/rabbit_version.erl
index 047737a4..c629180e 100644
--- a/src/rabbit_version.erl
+++ b/src/rabbit_version.erl
@@ -16,7 +16,7 @@
-module(rabbit_version).
--export([recorded/0, matches/2, compare/2, desired/0, desired_for_scope/1,
+-export([recorded/0, matches/2, desired/0, desired_for_scope/1,
record_desired/0, record_desired_for_scope/1,
upgrades_required/1]).
@@ -33,7 +33,6 @@
-spec(recorded/0 :: () -> rabbit_types:ok_or_error2(version(), any())).
-spec(matches/2 :: ([A], [A]) -> boolean()).
--spec(compare/2 :: ([A], [A]) -> ('eq' | 'lt' | 'gt' | 'incomparable')).
-spec(desired/0 :: () -> version()).
-spec(desired_for_scope/1 :: (scope()) -> scope_version()).
-spec(record_desired/0 :: () -> 'ok').
@@ -83,22 +82,6 @@ record_for_scope(Scope, ScopeVersion) ->
matches(VerA, VerB) ->
lists:usort(VerA) =:= lists:usort(VerB).
-compare(VerA, VerB) ->
- VerAS = lists:usort(VerA),
- VerBS = lists:usort(VerB),
- VerASPrefixVerBS = lists:prefix(VerAS, VerBS),
- VerBSPrefixVerAS = lists:prefix(VerBS, VerAS),
- if
- VerAS =:= VerBS ->
- eq;
- VerASPrefixVerBS ->
- lt;
- VerBSPrefixVerAS ->
- gt;
- true ->
- incomparable
- end.
-
%% -------------------------------------------------------------------
desired() -> [Name || Scope <- ?SCOPES, Name <- desired_for_scope(Scope)].