[erlang-bugs] mnesia dir not always created automatically

Matthias Radestock matthias@REDACTED
Tue May 8 19:58:05 CEST 2007


Mnesia usually creates the specified mnesia directory when that does not
yet exists. However, I have found one scenario where that doesn't happen
and mnesia crashes instead.

Here's the code:

-module(mnesiatest).

-export([start_master/0, start_slave/1]).

start_master() ->
    ok = mnesia:create_schema([node()]),
    ok = mnesia:start().

start_slave(MasterNode) ->
    ok = mnesia:start(),
    {ok, [MasterNode]} = mnesia:change_config(extra_db_nodes, [MasterNode]),
    mnesia:change_table_copy_type(schema, node(), disc_copies),
    halt().


and here is a transcript showing the problem:

$ mkdir /tmp/mnesiatest
$ erl -sname foo -mnesia dir '"/tmp/mnesiatest/foo"' -noshell -noinput -eval 'mnesiatest:start_master()' &
[1] 29026
$ erl -sname bar -mnesia dir '"/tmp/mnesiatest/bar"' -noshell -eval 'mnesiatest:start_slave(foo@REDACTED)'
$ rm /tmp/mnesiatest/bar/*
$ erl -sname bar -mnesia dir '"/tmp/mnesiatest/bar"' -noshell -eval 'mnesiatest:start_slave(foo@REDACTED)'
$ rm /tmp/mnesiatest/bar/*
$ rmdir /tmp/mnesiatest/bar
$ erl -sname bar -mnesia dir '"/tmp/mnesiatest/bar"' -noshell -eval 'mnesiatest:start_slave(foo@REDACTED)'
Mnesia(bar@REDACTED): Data may be missing, Corrupt logfile deleted: "/tmp/mnesiatest/bar/LATEST.LOG", {file_error,
                                                                                                    "/tmp/mnesiatest/bar/LATEST.LOG",
                                                                                                    enoent} 

=ERROR REPORT==== 8-May-2007::18:37:31 ===
Mnesia(bar@REDACTED): ** ERROR ** (core dumped to file: "/home/rade/experiments/erlang/MnesiaCore.bar@REDACTED")


As you can see, mnesia quite happily creates a directory for the master
node and a directory for the slave node the first time it is
started. The slave note restarts fine after its mnesia directory
*contents* have been wiped out. However, deleting the directory itself
results in a crash.


This is happening in R11B-4. I haven't tested earlier versions.


Regards,

Matthias



More information about the erlang-bugs mailing list