diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-11 13:46:05 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-11 13:46:05 +0100 |
commit | d1070ca614ae05c1170445edc0277e8a1b7ac514 (patch) | |
tree | 6694a8edefbfe220a1e0f50a60235e2de54179fd /src/rabbit_mnesia.erl | |
parent | 7aa2e63af4db3ddb8be9e7af861f1414719f7e8a (diff) | |
download | rabbitmq-server-d1070ca614ae05c1170445edc0277e8a1b7ac514.tar.gz |
The table content tests need to happen *after* we've waited for the tables, otherwise they can fail. Thus now two phases - schema checks, as before, and then table content checks.
Diffstat (limited to 'src/rabbit_mnesia.erl')
-rw-r--r-- | src/rabbit_mnesia.erl | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 4051d056..47abc2c7 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -92,6 +92,7 @@ init() -> ok = ensure_mnesia_running(), ok = ensure_mnesia_dir(), ok = init_db(read_cluster_nodes_config(), true), + ok = check_table_content(), ok = wait_for_tables(), ok. @@ -277,15 +278,27 @@ check_schema_integrity() -> Attrs = mnesia:table_info(Tab, attributes), Error = {table_attributes_mismatch, Tab, ExpAttrs, Attrs}, - case Attrs of - ExpAttrs -> - {_, Match} = proplists:lookup(match, TabDef), - not read_test_table(Tab, Match); - _ -> true - end + Attrs /= ExpAttrs end] of [] -> ok; - Errors -> {error, Errors} + Errors -> io:format("~p~n", [Errors]), + rabbit_log:info("~p~n",Errors), + {error, Errors} + end. + +check_table_content() -> + ok = wait_for_tables(), + case lists:all(fun ({Tab, TabDef}) -> + {_, Match} = proplists:lookup(match, TabDef), + read_test_table(Tab, Match) + end, table_definitions()) of + true -> ok; + false -> error_logger:warning_msg( + "table content integrity check failed.~n" + "moving database to backup location " + "and recreating schema from scratch~n", []), + ok = move_db(), + ok = create_schema() end. read_test_table(Tab, Match) -> |