|
|
| Author |
Message |
|
| wyborowiec |
Posted: Wed Feb 03, 2010 1:12 pm |
|
|
|
Joined: 01 Dec 2008
Posts: 4
Location: Poland
|
Hello
I've got a disc Mnesia table, which is distributed on 2 nodes. I start first node this way:
Code:
erl -sname a -setcookie cookie -mnesia extra_db_nodes "['b@host']"
and second one:
Code:
erl -sname b -setcookie cookie -mnesia extra_db_nodes "['a@host']"
Then on node 'a' following steps take place:
Code:
net_adm:ping('b@host').
mnesia:start().
rd(test, {f1,f2}), Fields = record_info(fields, test).
mnesia:change_table_copy_type(schema, node(), disc_copies).
Similar steps on node 'b':
Code:
mnesia:start().
mnesia:change_table_copy_type(schema, node(), disc_copies).
and again on node 'a':
Code:
mnesia:create_table(test, [{disc_copies, [node()|nodes()]}, {attributes, Fields}]).
Until now everything is fine: I've got 1 empty table distributed on two nodes. Then I kill both Erlang consoles with CTRL+C: first 'a', then 'b'. Now I start node 'a' once again, start Mnesia on it and I try to execute a query:
Code:
mnesia:dirty_read({test, 1}).
the result is:
Code:
** exception exit: {aborted,{no_exists,[test,1]}}
in function mnesia:abort/1
I can see the table in mnesia:info, mnesia:table_info results, but it's impossible to read it. The situation comes back to normal when I start again Mnesia on 'b' node:
Code:
(a@host)7> mnesia:dirty_read({test, 1}).
[]
Why the table doesn't work when only one node is up? Is it normal, desired behavior?
I'll be grateful for any help |
|
|
| Back to top |
|
| uwiger |
Posted: Wed Feb 03, 2010 2:35 pm |
|
|
|
User
Joined: 03 Jul 2006
Posts: 604
Location: Sweden
|
wyborowiec wrote: I've got 1 empty table distributed on two nodes. Then I kill both Erlang consoles with CTRL+C: first 'a', then 'b'. Now I start node 'a' once again, start Mnesia on it and I try to execute a query:
The explanation for this is that when 'a' dies, Mnesia on 'b' logs it as down in its decision log. When mnesia on 'a' comes back up, it has no information about 'b', but notices that it is now down. It must then assume that 'b' was alive when 'a' died, and therefore has a more recent copy of the database. It then decides to wait for 'b' to come back on line.
Mnesia is not very forthcoming about letting you know why it is not loading the tables. If you call mnesia:wait_for_tables(Tabs, Timeout), you will at least discover that they aren't being loaded. As a last resort (if you know that 'b' is not coming back anytime soon), you can force-load the tables on 'a'. Be careful, though, as force_loading while tables are being loaded the normal way can cause inconsistencies in the database. |
_________________ http://www.erlang-consulting.com |
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|