mnesia:report_event/1 seems to have a bug

Sergey Samokhin prikrutil@REDACTED
Wed Jun 17 23:13:05 CEST 2009


Hi!

I think I may have found a bug in mnesia:report_event/1: events generated by
this function aren't sent to another node.

Please, let me know if it isn't a bug, but a feature.

To reproduce the behaviour first open a new erlang shell which is supposed
to catch user events as shown below:

$ erl -sname a
Eshell V5.7.1  (abort with ^G)
(a@REDACTED)1> mnesia:start().
ok
(a@REDACTED)2> mnesia:subscribe(system).
{ok,a@REDACTED}
(a@REDACTED)3> Recv = fun() -> receive Msg -> Msg after 100 -> timeout end
end.

Recv() function I've just defined will then be used to check if a user event
came in.

Now start another node and then connect it to the first one:

$ erl -sname b
Eshell V5.7.1  (abort with ^G)
(b@REDACTED)1> mnesia:start().
ok
(b@REDACTED)2> mnesia:change_config(extra_db_nodes, [a@REDACTED]).
{ok,[a@REDACTED]}

To cleanup the mailbox of a@REDACTED from mnesia_up event we must call
Recv():

(a@REDACTED)4> Recv().
{mnesia_system_event,{mnesia_up,b@REDACTED}}

Now that our environment is ready to show where the problem is, let's
generate a user event:

(b@REDACTED)3> mnesia:report_event(foobar). % <-- Custom event is generated
Mnesia(nonode@REDACTED): User event: foobar
ok

...and then try to receive the corresponding message on a@REDACTED:

(a@REDACTED)5> Recv().
timeout % <-- there weren't messages to get from mailbox

Event "foobar" hasn't been sent to a@REDACTED I don't know why, but it
seems to be a bug, because the documentation to report-event/1 doesn't say
that a process supposed to handle user events has to be local:

"The Event may be any term and generates a {mnesia_user, Event} event for
any  processes  that  subscribe to Mnesia system events."

Hope it will help developers to fix the problem (if it is a problem, of
course).

I use Erlang R13B: Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]

-- 
Sergey Samokhin


More information about the erlang-bugs mailing list