[erlang-bugs] dets hangs sometimes

John Hughes <>
Tue May 17 15:02:46 CEST 2011


QuickCheck found another dets bug at Klarna. The following test makes dets hang:

run() ->
    dets:stop(),
    file:delete(dets_table),
    {ok,dets_table} = dets:open_file(dets_table,[{type,bag}]),
    ok = dets:insert(dets_table,[{0,21},{0,0},{1,0},{2,0},{2,1}]),
    ok = dets:insert(dets_table,[{1,21}]),
    true = dets:insert_new(dets_table,[{3,0}]),
    {[{1,21}],Cont} = dets:match_object(dets_table,{'$1',21},0),
    {[{0,21}],Cont2} = dets:match_object(Cont),
    ok = dets:match_delete(dets_table,{'$1','$2'}),
    true = dets:insert_new(dets_table,[{31,0}]), 
    ok = dets:insert(dets_table,[{2,1},{18,0},{31,1}]),
    ok = dets:insert(dets_table,[{1,0},{1,1},{2,0}]),
    [] = dets:match_object(dets_table,{0,0}),
    io:format("Here it comes..."),
    %% This call hangs
    dets:match_object(Cont2),
    io:format("now!\n").

When I run it:

2> c(dets_stopped).
{ok,dets_stopped}
3> dets_stopped:run().
Here it comes...

Make sure to run it in a newly started node... dets has some state which can change the behaviour.

Maybe it could be simplified some more, but most changes I make to it cause it to pass.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20110517/84f0a4b6/attachment.html>


More information about the erlang-bugs mailing list