Quantcast

Tracking progress of mnesia start

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Tracking progress of mnesia start

Attila Rajmund Nohl
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@172.17.0.4',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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracking progress of mnesia start

Karolis Petrauskas-2
Hi,

I use mnesia:wait_for_tables/2 in a loop with small timeout for that.
This function returns a list of missing tables in the case of timeout.

Karolis

On Mon, Mar 6, 2017 at 5:38 PM, Attila Rajmund Nohl
<[hidden email]> 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@172.17.0.4',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
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracking progress of mnesia start

Jesper Louis Andersen-2
In reply to this post by Attila Rajmund Nohl
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 <[hidden email]> 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,'[hidden email]',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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...