[erlang-questions] Tracking progress of mnesia start

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Mon Mar 6 17:08:57 CET 2017


await_loading(Tables) ->
    Parent = self(),
    _ = [spawn_link(fun() -> mnesia:wait_for_tables(T, ?TIMEOUT), Parent !
{loaded_table, T} end) || T <- Tables],
    await_loading_join(Tables, 0).

await_loading_join(Tables, Count) ->
    receive
        {loaded_table, T} ->
            await_loading(Tables -- [T], Count+1);
    after ?ARGH ->
            exit(argh)
    end.

Totally untested, but should easily be adaptable to something robust which
does things correctly. You will need some serious error-handling pathing in
the above such that you can handle the timeouts properly. Probably by
sending back an answer to the Parent with the fact that a certain load
timed out.

Also, you could do some stuff on top of this by logging how many tables are
loaded every 5 seconds via a timer and so on.


On Mon, Mar 6, 2017 at 4:38 PM Attila Rajmund Nohl <attila.r.nohl@REDACTED>
wrote:

> Hello!
>
> I'd like to provide feedback to the user when mnesia is started in out
> application (something like "4 out of 16 tables loaded"). My first
> idea was to mnesia:subscribe for events, but I can subscribe only
> after mnesia is started, so I might miss some tables. My second idea
> is to turn on debugging, add an event module (both via setting
> environment values). It kind of works, I receive events like
>
> {mnesia_system_event,
>              {mnesia_info,
>                  "Table ~w is loaded on ~w. s=~w, r=~w, lc=~w, f=~w,
> m=~w~n",
>                  [album,'c3@REDACTED
> ',ram_copies,nowhere,false,false,false]}},
>
> but it depends on the format of debugging message and even though this
> message hasn't changed in the last 7 years, I'm a bit uneasy about it.
> Do you have any better idea?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170306/4cffa721/attachment.htm>


More information about the erlang-questions mailing list