[erlang-questions] Log dumping not thread-safe?

Igor Ribeiro Sucupira igorrs@REDACTED
Wed Jul 29 01:52:29 CEST 2009


By default, Mnesia dumps the transaction log automatically every 3
minutes (or after each hundred of log writes).

What happens if I call mnesia:dump_log() at the same moment Mnesia is
doing an automatic dump? I expected the calls to be serialized, so
that one dump would only begin after the current dump finishes. But,
it doesn't seem to be the case, as I had a Mnesia crash dump caused by
one of my calls to mnesia:dump_log/0.

Actually, concurrent calls to mnesia:dump_log/0 are not serialized,
from what I understand from this:

1> mnesia:start().
ok
2> F = fun(F0) -> mnesia:dump_log(), F0(F0) end.
#Fun<erl_eval.6.13229925>
3> spawn(fun() -> F(F) end).
<0.54.0>
4> spawn(fun() -> F(F) end).
<0.1413.1>
5>
=ERROR REPORT==== 28-Jul-2009::20:53:26 ===
Mnesia(nonode@REDACTED): ** ERROR ** (ignoring core) ** FATAL **
mnesia_controller crashed: {{case_clause,

                     true},

                    [{mnesia_controller,

                      add_worker,

                      2},

                     {mnesia_controller,

                      handle_call,

                      3},

                     {gen_server,

                      handle_msg,

                      5},

                     {proc_lib,

                      init_p_do_apply,

                      3}]} state: {state,

                                   <0.40.0>,

                                   true,

                                   [],

                                   [],

                                   {0,

                                    nil},

                                   [],

                                   [],

                                   {0,

                                    nil},

                                   <0.1412.1>,

                                   [{dump_log,

                                     user,

                                     {<0.54.0>,

                                      #Ref<0.0.0.204553>}}],

                                   [],

                                   {interval,

                                    #Ref<0.0.0.53>},

                                   false}

=INFO REPORT==== 28-Jul-2009::20:53:29 ===
    application: mnesia
    exited: shutdown
    type: temporary



Thanks for replying.
Igor.


2009/7/28 Hakan Mattsson <hakan@REDACTED>:
> On Fri, 24 Jul 2009, Igor Ribeiro Sucupira wrote:
>
>> mnesia:dump_log() is not thread-safe. Am I right?
>
> What do you mean with thread-safe in this context?
>
>> In practice, that would mean you can never use this function, as
>> Mnesia could be dumping the log at the same moment you called this
>> function. Is that correct?
>
> No. Mnesia will start dumping its transaction log when you invoke this
> function. But it does not interfere with ongoing transactions. You can
> still use Mnesia as usual while the dump is progressing as a background
> job.
>
> /Håkan
> ---
> Håkan Mattsson (uabhams)
> Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list