summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-11-04 13:51:56 +0000
committerSimon MacMullen <simon@rabbitmq.com>2010-11-04 13:51:56 +0000
commit049791b8cc99fab058a18c5af230e781e7aac138 (patch)
tree86f211abcbc2eafdccbb87c8a71c517d52e34999
parent56385940ddec8e087edc64dbaf3d7c0fe6934a3f (diff)
downloadrabbitmq-server-049791b8cc99fab058a18c5af230e781e7aac138.tar.gz
Keep the old behaviour when upgrading from 2.1.0 or earlier.
-rw-r--r--src/rabbit_mnesia.erl46
-rw-r--r--src/rabbit_upgrade.erl4
2 files changed, 29 insertions, 21 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index 35be1700..31a91b4d 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -377,29 +377,21 @@ init_db(ClusterNodes, Force) ->
{[], true, [_]} ->
%% True single disc node, attempt upgrade
wait_for_tables(),
- rabbit_upgrade:maybe_upgrade(),
- case check_schema_integrity() of
+ case rabbit_upgrade:maybe_upgrade() of
ok ->
- ok;
- {error, Reason} ->
- throw({schema_invalid_after_upgrade, Reason})
+ case check_schema_integrity() of
+ ok ->
+ ok;
+ {error, Reason} ->
+ throw({schema_invalid_after_upgrade,
+ Reason})
+ end;
+ version_not_available ->
+ schema_ok_or_move()
end;
{[], true, _} ->
%% First disc node in cluster, verify schema
- case check_schema_integrity() of
- ok ->
- ok;
- {error, Reason} ->
- %% NB: we cannot use rabbit_log here since
- %% it may not have been started yet
- error_logger:warning_msg(
- "schema integrity check failed: ~p~n"
- "moving database to backup location "
- "and recreating schema from scratch~n",
- [Reason]),
- ok = move_db(),
- ok = create_schema()
- end;
+ schema_ok_or_move();
{[], false, _} ->
%% First RAM node in cluster, start from scratch
ok = create_schema();
@@ -434,6 +426,22 @@ init_db(ClusterNodes, Force) ->
ClusterNodes, Reason}})
end.
+schema_ok_or_move() ->
+ case check_schema_integrity() of
+ ok ->
+ ok;
+ {error, Reason} ->
+ %% NB: we cannot use rabbit_log here since
+ %% it may not have been started yet
+ error_logger:warning_msg(
+ "schema integrity check failed: ~p~n"
+ "moving database to backup location "
+ "and recreating schema from scratch~n",
+ [Reason]),
+ ok = move_db(),
+ ok = create_schema()
+ end.
+
create_schema() ->
mnesia:stop(),
rabbit_misc:ensure_ok(mnesia:create_schema([node()]),
diff --git a/src/rabbit_upgrade.erl b/src/rabbit_upgrade.erl
index 9262ebab..37bac90d 100644
--- a/src/rabbit_upgrade.erl
+++ b/src/rabbit_upgrade.erl
@@ -32,7 +32,7 @@
-ifdef(use_specs).
--spec(maybe_upgrade/0 :: () -> 'ok').
+-spec(maybe_upgrade/0 :: () -> 'ok' | 'version_not_available').
-spec(read_version/0 ::
() -> {'ok', [any()]} | rabbit_types:error(any())).
-spec(write_version/0 :: () -> 'ok').
@@ -62,7 +62,7 @@ maybe_upgrade() ->
true = digraph:delete(G),
ok;
{error, enoent} ->
- ok
+ version_not_available
end.
read_version() ->