<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi,<div><br></div><div>I'm running a select with a continuation on a public ets table with approximately 20,000 records.</div><div><br></div><div>The original call to the select is: <span style="font-size: 10pt; ">ets:select(</span><span class="s1" style="font-size: 10pt; ">TableName</span><span style="font-size: 10pt; ">,[{'$1',[],['$_']}],</span><span class="s1" style="font-size: 10pt; ">RecordsToGet</span><span style="font-size: 10pt; ">), then an ets:select/1 on the continuation.</span></div><div><span style="font-size: 10pt; "><br></span></div>







<div>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.</div><div><br></div><div>Every now and then I get an exception in the process doing the select/1:</div><div><br></div><div><div>Error in process <0.16218.1> on node 'xxxxx@E039D7001180' with exit value: {badarg,[{ets,select,[{'table_E0:39:D7:00:11:80',301,6,<<0 bytes>>,[{p_MacEntry.......  (truncated here)</div><div><br></div><div>This is the code (all running in the same process that started the select) obviously the last ets:select is causing the crash:</div><div><br></div><div>







<p class="p1"><span class="s1">start_aging1(</span>AgeInterval<span class="s1">,</span>MaxAge<span class="s1">,</span>SelectData<span class="s1">) </span><span class="s2">-></span></p>
<p class="p1"><span class="s1"><span class="Apple-tab-span"></span>     start_aging1(</span>AgeInterval<span class="s1">,</span>MaxAge<span class="s1">,</span>SelectData<span class="s1">,</span><span class="s3">0</span><span class="s1">).</span></p>
<p class="p2">start_aging1(<span class="s4">_AgeInterval</span>,<span class="s4">_MaxAge</span>,'$end_of_table',<span class="s4">RecsAged</span>) <span class="s2">-></span></p>
<p class="p2"><span class="Apple-tab-span"></span>     gen_server:cast(<span class="s5">?MODULE</span>,{completed_aging_operation,<span class="s4">RecsAged</span>});</p>
<p class="p2">start_aging1(<span class="s4">_AgeInterval</span>,<span class="s4">MaxAge</span>,{<span class="s4">Matches</span>,'$end_of_table'},<span class="s4">RecsAged</span>) <span class="s2">-></span></p>
<p class="p2"><span class="Apple-tab-span"></span><span class="s4">     RecordsAgedCount</span> = age_records(<span class="s4">Matches</span>,[],<span class="s4">MaxAge</span>*<span class="s3">1000000</span>,os:timestamp()),</p>
<p class="p2"><span class="Apple-tab-span"></span>     gen_server:cast(<span class="s5">?MODULE</span>,{completed_aging_operation,<span class="s4">RecsAged</span>+<span class="s4">RecordsAgedCount</span>});</p>
<p class="p1"><span class="s1">start_aging1(</span>AgeInterval<span class="s1">,</span>MaxAge<span class="s1">,{</span>Matches<span class="s1">,</span>Continuation<span class="s1">},</span>RecsAged<span class="s1">) </span><span class="s2">-></span></p>
<p class="p2"><span class="Apple-tab-span"></span><span class="s4">     RecordsAgedCount</span> = age_records(<span class="s4">Matches</span>,[],<span class="s4">MaxAge</span>*<span class="s3">1000000</span>,os:timestamp()),</p>
<p class="p2"><span class="Apple-tab-span"></span>     timer:sleep(<span class="s4">AgeInterval</span>),</p>
<p class="p2"><span class="s1" style="font-size: 10pt; ">     start_aging1(</span><span style="font-size: 10pt; ">AgeInterval</span><span class="s1" style="font-size: 10pt; ">,</span><span style="font-size: 10pt; ">MaxAge</span><span class="s1" style="font-size: 10pt; ">,</span><span class="s1" style="font-size: 10pt; ">ets:select(<span class="s4">Continuation</span>),</span><span style="font-size: 10pt; ">RecsAged</span><span class="s1" style="font-size: 10pt; ">+</span><span style="font-size: 10pt; ">RecordsAgedCount</span><span class="s1" style="font-size: 10pt; ">).</span></p>
<p class="p3"><br><span class="s1"></span></p></div><div>I'm not sure what could be the cause of the select getting a bad arg.</div><div><br></div><div>Any ideas?</div><div><br></div><div>Thanks</div><div><br></div><div>Matt                                          </div><div>  </div></div>                                    </div></body>
</html>