Mnesia Bug with select and disc_only_copies tables

Dan Gudmundsson dgud@REDACTED
Wed Oct 5 08:35:01 CEST 2005


Rudolph van Graan writes:
 > >
 > > See the manual:
 > >
 > >  For efficiency
 > >           the NObjects is a recommendation only  and  the  result
 > >           may  contain  anything from an empty list to all avail-
 > >           able results.
 > 
 > 
 > Does "Empty list" here mean "empty" even though the query matched  
 > results? Or does it mean "Empty" when there was no results? For me  
 > "recommendation" means that the query should return *at most*  
 > NObjects if any results matched, or if the continuation mechanism  
 > fails (for dets) *all* the data. But not nothing.

It means that for this invocation there where no matching results, 
keep on looping until $end_of_table is reached.

NObjects in the dets case means how many objects dets should read from
file, i.e. read NObjects objects, run the match spec on them return the
matching ones.

So in example below, the empty list could have been returned 100 times
before returning the expected result in the last call.

 > 
 > My experience shows that by only removing the NObjects argument, the  
 > query worked, otherwise it did not return *any* data. The same query  
 > without NObjects did return data.
 > 
 > I haven't had time to dig around too much, but your code runs here as  
 > well. My table has indices, which might be part of the issue. I am  
 > happy if the query *ignores* the NObject, but not for it to return no  
 > data.
 > 
 > Do you want me to try and narrow this down to a reproducable scenario?

That whould be nice, you can email me directly

/Dan

 > 
 > 
 > >
 > > (it is written because of dets :-)
 > >
 > > It works here:
 > >
 > > 1> mnesia:start().
 > > 2> mnesia:create_table(a, []).
 > > {atomic,ok}
 > > 6> mnesia:change_table_copy_type(schema, node(), disc_copies).
 > > {atomic,ok}
 > > 7> [mnesia:dirty_write({a, N,N}) || N <- lists:seq(1,1000)].
 > > 8> mnesia:change_table_copy_type(a, node(), disc_only_copies).
 > > {atomic,ok}
 > > 14> P = ets:fun2ms(fun({a,_,A}) when A > 990 -> A end).
 > > 16> F = fun('$end_of_table', _, Acc) -> Acc;
 > >            ({Recs,Cont}, Fun,Acc) ->
 > >            R = mnesia:select(Cnt),
 > >                Fun(R, Fun, Recs ++Acc)
 > >         end.
 > > 17> mnesia:transaction(fun() ->
 > >                  Cont = mnesia:select(a, P, 10, read),
 > >                  F(Cont, F, [])
 > >                end).
 > > {atomic,[996,997,1000,998,994,992,993,995,999,991]}
 > Regards,
 > 
 > Rudolph




More information about the erlang-questions mailing list