diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-06-24 12:31:48 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-06-24 12:31:48 +0100 |
| commit | 583511797127748468d289dcce26d055b6d849dc (patch) | |
| tree | 47db0ff0f9fdb6e7ad2601745fc59065ce225dd3 /src | |
| parent | cca6c8128e4ddf2623c3bf837e07e51cd6a34d69 (diff) | |
| download | rabbitmq-server-git-583511797127748468d289dcce26d055b6d849dc.tar.gz | |
Removed the dumb timer:sleep, and after testing, properly sorted out the mnesia clustering details. This means that wait_for_tables now waits for _all_ tables which means the bug that was requiring the timer:sleep has gone away.
The solution to the clustering issue was to make sure that tables which are local content only are created explicitly on each node before you call wait_for_tables.
All tests pass.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_misc.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_mnesia.erl | 33 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index f38ee63155..2971e33265 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -409,7 +409,7 @@ format_stderr(Fmt, Args) -> manage_applications(Iterate, Do, Undo, SkipError, ErrorTag, Apps) -> Iterate(fun (App, Acc) -> case Do(App) of - ok -> timer:sleep(100), [App | Acc]; + ok -> [App | Acc]; {error, {SkipError, _}} -> Acc; {error, Reason} -> lists:foreach(Undo, Acc), diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 6c583cb47b..0201017c0b 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -158,12 +158,14 @@ replicated_table_definitions() -> not lists:member({local_content, true}, Attrs) ]. +non_replicated_table_definitions() -> + [{Tab, Attrs} || {Tab, Attrs} <- table_definitions(), + lists:member({local_content, true}, Attrs) + ]. + table_names() -> [Tab || {Tab, _} <- table_definitions()]. -replicated_table_names() -> - [Tab || {Tab, _} <- replicated_table_definitions()]. - dir() -> mnesia:system_info(directory). ensure_mnesia_dir() -> @@ -189,7 +191,7 @@ ensure_mnesia_not_running() -> check_schema_integrity() -> %%TODO: more thorough checks case catch [mnesia:table_info(Tab, version) - || Tab <- replicated_table_names()] of + || Tab <- table_names()] of {'EXIT', Reason} -> {error, Reason}; _ -> ok end. @@ -292,12 +294,13 @@ init_db(ClusterNodes) -> ok = create_schema() end; {ok, [_|_]} -> + TableCopyType = case IsDiskNode of + true -> disc; + false -> ram + end, + ok = create_local_non_replicated_table_copies(TableCopyType), ok = wait_for_tables(), - ok = create_local_table_copies( - case IsDiskNode of - true -> disc; - false -> ram - end); + ok = create_local_replicated_table_copies(TableCopyType); {error, Reason} -> %% one reason we may end up here is if we try to join %% nodes together that are currently running standalone or @@ -348,7 +351,13 @@ create_tables() -> table_definitions()), ok. -create_local_table_copies(Type) -> +create_local_replicated_table_copies(Type) -> + create_local_table_copies(Type, replicated_table_definitions()). + +create_local_non_replicated_table_copies(Type) -> + create_local_table_copies(Type, non_replicated_table_definitions()). + +create_local_table_copies(Type, TableDefinitions) -> ok = create_local_table_copy(schema, disc_copies), lists:foreach( fun({Tab, TabDef}) -> @@ -384,7 +393,7 @@ create_local_table_copies(Type) -> end, ok = create_local_table_copy(Tab, StorageType) end, - table_definitions()), + TableDefinitions), ok. create_local_table_copy(Tab, Type) -> @@ -402,7 +411,7 @@ create_local_table_copy(Tab, Type) -> wait_for_tables() -> case check_schema_integrity() of ok -> - case mnesia:wait_for_tables(replicated_table_names(), 30000) of + case mnesia:wait_for_tables(table_names(), 30000) of ok -> ok; {timeout, BadTabs} -> throw({error, {timeout_waiting_for_tables, BadTabs}}); |
