[erlang-questions] ets table disappears after bad query

Todd t.greenwoodgeer@REDACTED
Mon May 2 07:54:57 CEST 2011


I have an ets query that is broken. The funny thing is that after the 
query fails, the ets table disappears...

Here's the code...mostly ripped off from the file doc entry:
git://gist.github.com/951214.git

REPRO:

1. the ets table does not exist

127> ets:all().
[8207,4110,13,file_io_servers,inet_hosts_file_byaddr,
  inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname,
  inet_cache,inet_db,global_pid_ids,global_pid_names,
  global_names_ext,global_names,global_locks,ac_tab]
128>

2. running the test creates the ets table, 'file_test'

dynamic_file:test(). 

-----------------------------------------
create_file_slow
-----------------------------------------
create_file_slow,4884,1024,0.20966420966420968,1,
create_file_slow,16569,2048,0.1236043213229525,1,
create_file_slow,41857,4096,0.09785698927300093,1,
create_file_slow,135915,8192,0.060272964720597434,1,
create_file_slow,564260,16384,0.029036259880197073,1,
create_file_slow,525989,32768,0.062297880754160255,1,
-----------------------------------------
create_file (fast)
-----------------------------------------
create_file,13306,1024,0.07695776341500075,1,
create_file,2907,1024,0.3522531819745442,2,
create_file,1435,1024,0.713588850174216,4,
create_file,740,1024,1.3837837837837839,8,
...
create_file,468,1024,2.1880341880341883,16,
create_file,3132,32768,10.462324393358877,2048,
create_file,3556,32768,9.214848143982003,4096,
ok

3. verify the ets entry exists (it does)

129> ets:all().
[file_test,8207,4110,13,file_io_servers,
  inet_hosts_file_byaddr,inet_hosts_file_byname,
  inet_hosts_byaddr,inet_hosts_byname,inet_cache,inet_db,
  global_pid_ids,global_pid_names,global_names_ext,
  global_names,global_locks,ac_tab]


4. run my broken query. i'm trying to sort the results by a specific 
column so that I can find what block size results in the best 
performance...not sure yet what's wrong with the query, but i'll figure 
it out:

130> lists:sort(fun({_,_,_,A,_}, {_,_,_,B,_}) -> A < B end, 
ets:match(file_test, {create_file, '$0', '$1', '$2', '$3'})).
** exception error: no function clause matching 
erl_eval:'-inside-an-interpreted-fun-'([13306,1024,0.07695776341500075,1],
[2907,1024,0.3522531819745442,2])

5. look at the ets tables again, and whoa, the 'file_test' table is gone!

131>
ets:all(). 

[8207,4110,13,file_io_servers,inet_hosts_file_byaddr,
  inet_hosts_file_byname,inet_hosts_byaddr,inet_hosts_byname,
  inet_cache,inet_db,global_pid_ids,global_pid_names,
  global_names_ext,global_names,global_locks,ac_tab]

6. Is this expected behaviour? What would I have to do to prevent losing 
my ets table?

-Todd



More information about the erlang-questions mailing list