Hi to all,<br><br>I have started studying Mnesia recently, and as a test I've wrote the<br>following simple program:<br><br><div>-module(mnesiatest).</div><div>-compile([export_all]).</div><div><br></div><div>
-include_lib("stdlib/include/qlc.hrl").</div><div><br></div><div>-record(registered_symbol, {symbol, date}).</div><div><br></div><div>test_no_wait() -></div><div><span style="white-space: pre;"> </span>mnesia:start(),
</div><div><span style="white-space: pre;"> </span>Fun = fun() -><span style="white-space: pre;"><br>        </span>         Q = qlc:q([E || E <- mnesia:table(registered_symbol)]),</div><div><span style="white-space: pre;">
        </span>         qlc:e(Q)<span style="white-space: pre;"><br>    </span>      end,</div><div><span style="white-space: pre;">   </span>mnesia:transaction(Fun).</div><div><br>So test_no_wait() basically starts Mnesia and does a query of
<br>all the records registered in the registered_symbol table. Now if I run this program,<br>I get the following error (using Erlang R12B on Mac OS X 10.4, PPC):<br></div><br><div><div>10> mnesiatest:test_no_wait().</div>
<div>{aborted,{no_exists,registered_symbol}}
</div><div><br>Although the record registered_symbol is defined in the source code. But if I <br>change test_no_wait() to include a slight delay between mnesia:start() and the<br>querying:<br><br><div>test_wait() -></div>
<div><span style="white-space: pre;">     </span>mnesia:start(),</div>        %% Blocks for 10 seconds<br><div><span style="white-space: pre;">        </span>receive</div><div>        after 10000 ->
</div><div><span style="white-space: pre;"> </span>    true</div><div>        end,</div><div><span style="white-space: pre;">      </span>Fun = fun() -><span style="white-space: pre;"><br>        </span>         Q = qlc:q([E || E <- mnesia:table(registered_symbol)]),
</div><div><span style="white-space: pre;"> </span>         qlc:e(Q)<span style="white-space: pre;"><br>    </span>      end,</div><div><span style="white-space: pre;">   </span>mnesia:transaction(Fun).</div><div><br></div>and run this version:
<br><br>11> mnesia:stop().</div><div><br></div><div>=INFO REPORT==== 20-Jan-2008::17:27:16 ===</div><div>    application: mnesia</div><div>    exited: stopped</div><div>    type: temporary
</div><div>stopped</div><div>12> mnesiatest:test_wait().   </div>{atomic,[{registered_symbol,"IBM",{2008,1,20}}]}<div>13> </div><div><br>then my query works, but I find this behavior a bit strange. It looks like
<br>some Mnesia initialization is still going on after my call to<br>mnesia:start(), but shouldn't mnesia:start() block until Mnesia is fully<br>initialized? or shouldn't at least mnesia:transaction(Fun) do this? Or is 
<br>there any command that I should be calling that blocks until everything<br>is initialized?<br><br>In case it helps, this is the call I am using to define my database:<br><br><div>init() -></div><div>       mnesia:create_table(registered_symbol, [{disc_copies, [node()]}, {attributes, record_info(fields, registered_symbol)}]).
</div><br>Thanks for the help,<br><br>Artur.<br><br><br></div></div>