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 | c2ff58c43e96f0a077804e73d11d027b625798af (patch) | |
| tree | 6694a8edefbfe220a1e0f50a60235e2de54179fd /src | |
| parent | a76cf88e73eab206bd797f2bb2bfc51d57b28c57 (diff) | |
| download | rabbitmq-server-git-c2ff58c43e96f0a077804e73d11d027b625798af.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')
| -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 4051d05685..47abc2c799 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) -> |
