[erlang-questions] ets:select badarg question (R15B)

Matthew Evans <>
Sun Oct 14 22:58:43 CEST 2012

I'm running a select with a continuation on a public ets table with approximately 20,000 records.
The original call to the select is: ets:select(TableName,[{'$1',[],['$_']}],RecordsToGet), then an ets:select/1 on the continuation.

The process that is spawned to walk the table is sitting in a recursive loop doing a select (grabbing about 150 records each time), processing the matching records (which includes possibly deleting some of these records), then sleeping for a few seconds. It takes about 900 seconds to walk through the table. As well as records getting deleted, new records are added to the table during this time.
Every now and then I get an exception in the process doing the select/1:
Error in process <0.16218.1> on node '' with exit value: {badarg,[{ets,select,[{'table_E0:39:D7:00:11:80',301,6,<<0 bytes>>,[{p_MacEntry.......  (truncated here)
This is the code (all running in the same process that started the select) obviously the last ets:select is causing the crash:

start_aging1(AgeInterval,MaxAge,SelectData) ->
start_aging1(_AgeInterval,_MaxAge,'$end_of_table',RecsAged) ->
start_aging1(_AgeInterval,MaxAge,{Matches,'$end_of_table'},RecsAged) ->
     RecordsAgedCount = age_records(Matches,[],MaxAge*1000000,os:timestamp()),
start_aging1(AgeInterval,MaxAge,{Matches,Continuation},RecsAged) ->
     RecordsAgedCount = age_records(Matches,[],MaxAge*1000000,os:timestamp()),

I'm not sure what could be the cause of the select getting a bad arg.
Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121014/20652708/attachment.html>

More information about the erlang-questions mailing list