<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16421">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>QuickCheck turned up another case of odd behaviour
at Klarna.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>The test runs mnesia on two nodes, creates a table
on the OTHER node, then adds and deletes a record. After this the record is
indeed not IN the table, but dirty_next finds its key anyway! Surely it
shouldn't?</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Here's the test:</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>test() -><BR> Slave =
start_mnesia_with_slave(),<BR> {atomic,ok} =
mnesia:create_table(rec,[{type,set},<BR>
{disc_only_copies,[Slave]}]),<BR>
ok =
mnesia:dirty_write({rec,4,1}),<BR> %% The next command MUST be
done in a transaction, otherwise dirty_next works<BR>
{atomic,ok} = mnesia:transaction(fun()->mnesia:delete_object({rec,4,1})
end),<BR> %% Here's the problem: dirty_next returns 4, but
this key is not in the table!<BR>
4 =
mnesia:dirty_next(rec,0),<BR>
[] =
mnesia:dirty_read(rec,4).<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial>I'm starting mnesia and the slave node like
this:</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>start_mnesia_with_slave()
-><BR> {ok,Dir} = file:get_cwd(),<BR> ok
= error_logger:tty(false),<BR>
mnesia:stop(),<BR> ok =
error_logger:tty(true),<BR>
delete_file("mnesia"),<BR>
delete_file("slave"),<BR> ok =
file:make_dir("mnesia"),<BR> ok =
file:make_dir("slave"),<BR> Slave =
slave(),<BR> ok =
application:set_env(mnesia,dir,Dir++"/mnesia"),<BR> ok =
rpc:call(Slave,application,set_env,[mnesia,dir,Dir++"/slave"]),<BR>
ok = mnesia:create_schema([node(),Slave]),<BR> ok =
mnesia:start(),<BR> ok =
rpc:call(Slave,mnesia,start,[]),<BR> Slave.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>slave() -><BR> case
slave:start_link(net_adm:localhost(),"slave") of<BR> {ok,Slave}
-><BR>
Slave;<BR> {error,{already_running,Slave}}
-><BR> Slave<BR>
end.<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial>I also have code to delete a file or directory,
easy on Linux, darn difficult on Windows. You don't need this really, just run
the test in an empty directory.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>delete_file(Name) -><BR> case
filelib:is_dir(Name) of<BR> true -><BR>
[delete_file(Name++"/"++X) || X <-
list_dir(Name)],<BR>
file:del_dir(Name),<BR>
delete_file(Name);<BR> {error,eaccess} -><BR>
delete_file(Name);<BR> {error,enoent} -><BR>
io:format("Could not find ~p\n",[Name]),<BR>
ok;<BR> false -><BR> case file:delete(Name)
of<BR> {error,enoent} -><BR>
ok;<BR> {error,eacces} -><BR>
io:format("Could not access ~p\n",[Name]),<BR>
delete_file(Name);<BR> ok -><BR>
delete_file(Name)<BR> end<BR>
end.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>list_dir(Name) -><BR> case
file:list_dir(Name) of<BR> {ok,Files} -><BR>
Files;<BR> {error,eacces} -><BR>
io:format("Could not list directory ~p\n",[Name]),<BR>
list_dir(Name);<BR> {error,enoent} -><BR>
io:format("Could not find directory ~p\n",[Name]),<BR>
[] <BR> end.<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial>John</DIV></FONT></BODY></HTML>