[erlang-bugs] dets hangs sometimes
John Hughes
john.hughes@REDACTED
Tue May 17 16:10:00 CEST 2011
Ah, thank you. I'll try running tests with safe_fixtable included.
John
----- Original Message -----
From: "Hans Bolinder" <hans.bolinder@REDACTED>
To: <erlang-bugs@REDACTED>
Sent: Tuesday, May 17, 2011 3:24 PM
Subject: Re: [erlang-bugs] dets hangs sometimes
> Hi again!
>
> [John Hughes:]
>> 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.
>
> It's not a bug. You can try adding the line
>
> dets:verbose(),
>
> It'll then output
>
> =ERROR REPORT==== 17-May-2011::15:20:42 ===
> ** dets: traversal of dets_table needs safe_fixtable
>
> The manual states that
>
> The table should always be protected using safe_fixtable/2
> before calling match_object/3, or errors may occur when call-
> ing match_object/1.
>
> Adding
>
> dets:safe_fixtable(dets_table, true),
>
> before match_object seems to make it work.
>
> Best regards,
>
> Hans Bolinder, Erlang/OTP team, Ericsson
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
>
More information about the erlang-bugs
mailing list