mnesia subscription
Tobias Schlager <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I just found out the hard way, that mnesia:subscribe/1 might lie to you, when you trap exits and are linked to other processes. Although running, Mnesia sometimes returns '{error,{node_not_running,nonode@nohost}}' when trying to subscribe. Even worse subsequent calls to subscribe from the same process tell you that the subscription actually took place (returning '{error,{already_exists,Category}}'). This is due to a receive statement located in mnesia_subscr:call/1 that tries to unify the functions return value. Unfortunately, it doesn't match for a specific process id, so every 'EXIT' message in the callers message queue will be consumed and trigger the false value.
For a minimal test case fire up an erlang shell and do the following:
1> application:start(mnesia).
ok
2> process_flag(trap_exit, true).
false
3> spawn_link(fun() -> ok end).
<0.52.0>
4> mnesia:subscribe(system).
{error,{node_not_running,nonode@nohost}}
5> mnesia:subscribe(system).
{error,{already_exists,system}}
6> mnesia:unsubscribe(system).
{ok,nonode@nohost}
7> mnesia:subscribe(system).
{ok,nonode@nohost}
Regards
Tobias
_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs