[erlang-questions] Detecting 'inconsistent_database' and other Mnesia events

Serge Aleynikov serge@REDACTED
Thu Jan 11 15:48:13 CET 2007


In my experience getting "inconsistent_database" event at startup is a 
rather uncommon event (we've only seen it during testing when one master 
node was in the middle of a mnesia:wait_for_tables/2 call, while the 
other master node would get restarted, but even then the call to 
mnesia:subscribe/1 succeeded prior to doing mnesia:wait_for_tables/2, 
and the event was handled properly).

However I see your point and it doesn't sound like a bad thing to add a 
startup option in order to avoid that possible race condition.

As far as the error_logger approach is concerned, the event term is:

{error, GL, {Pid, Format, Args}}

where
     Format =
         "Mnesia(~p): ** ERROR ** mnesia_event got 
{inconsistent_database, ~w, ~w}~n",
     Args =
         [MnesiaNode,Reason,Node]}}

though this is a rather absurd way of detecting the fault.  :-(

Regards,

Serge

Scott Lystig Fritchie wrote:
> Good evening.  As I've been refactoring a Mnesia-based application, it
> struck me that mnesia:subscribe/1 cannot be called until Mnesia has
> been started.
> 
> As a Mnesia event subscriber, if I want extremely *prompt* and
> *reliable* notification of important events such as the
> 'inconsistent_database' warning ... hm, it seems I'm stuck with a race
> condition, possibly missing the event between starting Mnesia and
> becoming an event subscriber.
> 
> My solution, before refactoring, was to have my custom error_logger
> report handler check for "inconsistent_database" in any string that it
> was about to write to disk.  Not very elegant, but effective.
> 
> After refactoring, my report handler is now in a hunk of code that
> can/will be shared by many applications, and the code that reacts to
> the Mnesia error will differ from app to app.
> 
> So ... are there any easy ways around this problem, something I've
> missed?
> 
> -Scott
> 
> P.S. Hm.  Here's the only thing that I can come up with, hitting my
> brain about 5 seconds before pressing "Send".
> 
> 1. Add yet another custom report handler, foo, callback for
> error_logger.
> 
> 2. In foo.erl, have a callback func that looks something like:
> 
>     handle_event({_T, _GL, SomeWackyTermThing}, State) ->
>         scream_murder_then_halt_abruptly(),
>         {ok, State};
>     handle_event(_Event, State) ->
>         {ok, State}.
> 
> ... where SomeWackyTermThing is really whatever report/format/whatever
> that Mnesia logs when 'inconsistent_database' is detected.
> 
> 3. Fiddle a lot with creating Mnesia inconsistencies to try to figure
> out *exactly* what that !@#$! error logger event looks like.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list