diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-05 18:51:40 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-05 18:51:40 +0100 |
| commit | a4510d055fed78482536878c30f83c12b35206e4 (patch) | |
| tree | 126204fb0b1bf74d23a954a923f7572c0d58fd51 /src | |
| parent | fbdc8c26f8915d72548415e2ff20fe546968b2b8 (diff) | |
| download | rabbitmq-server-git-a4510d055fed78482536878c30f83c12b35206e4.tar.gz | |
check that mnesia table attributes are as expected
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_mnesia.erl | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index c808499b0d..af0f53b309 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -167,7 +167,8 @@ table_definitions() -> {attributes, record_info(fields, vhost)}, {disc_copies, [node()]}]}, {rabbit_config, - [{disc_copies, [node()]}]}, + [{attributes, [key, val]}, % same mnesia's default + {disc_copies, [node()]}]}, {rabbit_listener, [{record_name, listener}, {attributes, record_info(fields, listener)}, @@ -232,10 +233,29 @@ ensure_mnesia_not_running() -> end. check_schema_integrity() -> - %%TODO: more thorough checks - case catch [mnesia:table_info(Tab, version) || Tab <- table_names()] of - {'EXIT', Reason} -> {error, Reason}; - _ -> ok + try + % Check that all tables are present + case catch [mnesia:table_info(Tab, version) || Tab <- table_names()] of + {'EXIT', Reason} -> throw({missing_table, Reason}); + _ -> ok + end, + % Check that tables are defined correctly + TabDefs = table_definitions(), + lists:foreach(fun(Tab) -> + {_, TabDef} = proplists:lookup(Tab, TabDefs), + {_, ExpAttrs} = proplists:lookup(attributes, TabDef), + Attrs = mnesia:table_info(Tab, attributes), + case lists:usort(ExpAttrs) /= lists:usort(Attrs) of + true -> + throw({table_not_defined_correctly, Tab}); + _ -> + ok + end + end, table_names()), + ok + catch + throw:Why -> + {error, Why} end. %% The cluster node config file contains some or all of the disk nodes |
