[erlang-bugs] dets:from_ets EXIT error caused by large ets table and binary filename used in dets:open_file

David Cartt dcartt@REDACTED
Thu Dec 8 23:40:34 CET 2011


I'm getting an 'EXIT' error response from a call to dets:from_ets.  The
error response is shown below.

Steps to reproduce: Do dets:open_file/2 with a binary() type filename, then
a dets:from_ets/2 where the ets table is large (small ets tables don't
cause the error).  My guess is that the ets table needs to be large enough
that the dets:from_ets needs to use a temporary file.  Don't know if this
matters, but in my case the dets:open_file always creates a new file and
the ets table is type ordered_set..

The documentation for dets:open_file/2 states that the filename for the
file option can be a binary: {file, file:name()}.  file:name() includes the
binary() type.

dets:from_ets return result:
        {'EXIT',{function_clause,[{lists,thing_to_list,
                                 [<<"d:/misc/workspaces/Erlang
workspace/test1/scratch/fs_Node_test1@REDACTED">>]},
                          {lists,flatmap,2},
                          {file_sorter,next_temp,1},
                          {file_sorter,write_run,2},
                          {file_sorter,fun_run,5},
                          {file_sorter,do_sort,5},
                          {dets,do_sort,6},
                          {dets,do_finit,4}]}}


Code fragment:
DetsName = <<"db.dets">>,
Filename = filename:join(<<"d:/misc/workspaces/Erlang
workspace/test1/scratch">>, DetsName),
{error, enoent} = file:read_link_info(Filename),  %make sure the name is
unique
{ok, DetsName} = dets:open_file(DetsName, [{file, Filename} , {type, set},
{ram_file, true}]),
ok = dets:from_ets(DetsName, EtsName),

A "exception error: no match of right hand side value" exception occurs on
the "ok = dets:from_ets(DetsName, EtsName)" statement, obviously because ok
/= {'EXIT', ...}.

Changing the {file, Filename} option to {file, binary_to_list(Filename)} makes
the error go away.  The resultant dets table is about 2MB in size.

OS: Windows 7 64 bit
Erlang version (installed from the R14B04 release Windows Binary File
download) (erl +V): Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.8.5
Node name (node()): Node_test1@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20111208/447fe738/attachment.htm>


More information about the erlang-bugs mailing list